In Excel VBA, I have a user form similar to the following where the user enters an identification number and then the data is displayed in 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
In the user details form, I have a "Edit" button. Pressing the “Change” button will open another user form in which the user can change the data of this identification number, but obviously not the identification number itself. To do this, I need to transfer the identification number from the "User Information" form to "Edit User Form". Is there any way to do this?
The bottom of the Custom Show Details form to open the Edit Custom 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
, , , :
http://www.mrexcel.com/forum/excel-questions/671964-visual-basic-applications-pass-variables-between-user-forms.html
http://gregmaxey.mvps.org/word_tip_pages/userform_pass_data.html
http://peltiertech.com/Excel/PropertyProcedures.html