Use InputBox to Open Form

Roddi

New member
Local time
Today, 05:44
Joined
Jun 26, 2014
Messages
8
Hi all,
I want a user to enter a number into an input box and then based on the number in this box a form will be opened with records associated only with that employee number. (All employee numbers are stored as text)

The code below opens the form, but it is blank. How to fix it?

Private Sub cmdOpenAddKeys_Click()
Dim EmployeeNumber As String
EmployeeNumber = InputBox("Please Enter Employee Number:")

DoCmd.OpenForm "frmAddKeys", acNormal, , "[Forms]![frmAddKeys]![empno]=" & EmployeeNumber
End Sub

Thanks in advance.
 
Have you an On_load sub on the form frmAddKeys to get the parameter and load the data?

EDIT: could be OnOpen maybe better for you. Retrieve arguments you've passed this way and then tell him to load the data else it wont do anything! :)

Code:
someVarOrField = Me.OpenArgs
 
Have you an On_load sub on the form frmAddKeys to get the parameter and load the data?

EDIT: could be OnOpen maybe better for you. Retrieve arguments you've passed this way and then tell him to load the data else it wont do anything! :)

Code:
someVarOrField = Me.OpenArgs

I am a bit confused about OpenArgs and about passing arguments. Can you, please, elaborate?
 

Users who are viewing this thread

Back
Top Bottom