Hello everyone,
I have tried using the OpenArgs parameter to open another form ("Form1") as modal. WHen it opens I need it to go to a specific record based on the "txtemplID" field on the "frmEmployeeDetails" form. I have used the following code:
Activated from a button on "frmEmployeeDetails" form.
Private Sub cmdOpenFrm_Click()
Dim StrValue As String
StrValue = Me!txtEmpID.Value
'MsgBox "The value is " & StrValue 'I am doing this to check the string is correct. At this stage it returns an employee number as I expect.
DoCmd.OpenForm "form1", acNormal, , , , acDialog, StrValue
End Sub
In form "Form1" - form I am opening
Private Sub Form_Load()
Dim StrValue As String
'If OpenArgs property contains EmpID, find
' corresponding employee record and display it on
' form. For example,if the OpenArgs property
' contains "801029", move to first "801029"
' record.
StrValue = Forms!frmEmployeeDetails.OpenArgs
MsgBox "The value is " & StrValue 'It now doesn't the string as I received in the cmdOpenFrm_Click() module as above.
If Len(StrValue) > 0 Then
DoCmd.GoToControl txtEmpID
DoCmd.FindRecord StrValue
End If
End Sub
When I click the button the form (Form1) opens but nothing shows in the txtempID text box on the form. It is just a blank form. I note above, when I use the Msgbox to return the string value in the Form_Load module it doesn't return the string set in cmdOpenFrm_Click().
I have searched for the same error but found nothing, hence my appreciation for any help you can provide.
Kind regards,
Russel
I have tried using the OpenArgs parameter to open another form ("Form1") as modal. WHen it opens I need it to go to a specific record based on the "txtemplID" field on the "frmEmployeeDetails" form. I have used the following code:
Activated from a button on "frmEmployeeDetails" form.
Private Sub cmdOpenFrm_Click()
Dim StrValue As String
StrValue = Me!txtEmpID.Value
'MsgBox "The value is " & StrValue 'I am doing this to check the string is correct. At this stage it returns an employee number as I expect.
DoCmd.OpenForm "form1", acNormal, , , , acDialog, StrValue
End Sub
In form "Form1" - form I am opening
Private Sub Form_Load()
Dim StrValue As String
'If OpenArgs property contains EmpID, find
' corresponding employee record and display it on
' form. For example,if the OpenArgs property
' contains "801029", move to first "801029"
' record.
StrValue = Forms!frmEmployeeDetails.OpenArgs
MsgBox "The value is " & StrValue 'It now doesn't the string as I received in the cmdOpenFrm_Click() module as above.
If Len(StrValue) > 0 Then
DoCmd.GoToControl txtEmpID
DoCmd.FindRecord StrValue
End If
End Sub
When I click the button the form (Form1) opens but nothing shows in the txtempID text box on the form. It is just a blank form. I note above, when I use the Msgbox to return the string value in the Form_Load module it doesn't return the string set in cmdOpenFrm_Click().
I have searched for the same error but found nothing, hence my appreciation for any help you can provide.
Kind regards,
Russel