Within Excel VBA I have a User Form similar to the following where the user enters an ID number and then the details are displayed on the user form:
Private Sub btnIDNo_Click()
Dim IDNo As Long
If txtIDNo.Text <> "" Then
If IsNumeric(txtIDNo.Text) = True Then
lblError.Caption = ""
IDNo = txtIDNo.Text
Worksheets("Details").Activate
Range("B4").Select
While ActiveCell.Value <> "" And ActiveCell.Value <> IDNo
ActiveCell.Offset(1, 0).Select
Wend
If ActiveCell.Value = IDNo Then
txtName.Value = ActiveCell.Offset(0, 1).Value
txtPhone.Value = ActiveCell.Offset(0, 2).Value
Else
lblError.Caption = "Cannot find ID nummber"
End If
Else
lblError.Caption = "Please enter the ID Number in numeric form"
End If
End If
End Sub
On the Details User Form, I have an "Edit" button. Clicking the "Edit" button would open another user form where the user can change the details of that ID number, but obviously not the ID number itself. To do this, I need to pass the ID number from the Details User Form to the Edit User Form. Is there a way of doing this?
The bottom on the Show Details User Form to open the Edit User Form is similar to the following:
Private Sub CommandButton1_Click()
Dim IDNo As Long
If txtIDNo.Text <> "" Then
If IsNumeric(txtIDNo.Text) = True Then
lblError.Caption = ""
IDNo= txtIDNo.Text
ufmEditDetails.Show
ufmShowDetails.Hide
Else
lblError.Caption = "Please enter the ID Number in numeric form"
End If
Range("B4").Select
End If
End Sub
I have already looked at the following links but they don't seem to help:
http://gregmaxey.mvps.org/word_tip_pages/userform_pass_data.html