Open a form and pass a parameter

A

Alan T

I have a main form displayere list of employees.
I would like to open a second form to display the details of a selected
employee. How can I do that?

One way I am thinking of is pass the employee number as argument when open
the second form.
 
F

fredg

I have a main form displayere list of employees.
I would like to open a second form to display the details of a selected
employee. How can I do that?

One way I am thinking of is pass the employee number as argument when open
the second form.

You don't need to pass the second form the employee number.
All you need do is open the second form (from the already open first
form) using the where argument of the DoCmd.OpenForm method.

Assuming the [EmployeeID] datatype is Number:
DoCmd.OpenForm "Form2", , , "[EmplyeeID] = " & Me![EmployeeID]

Form2 will open showing the records of the employee selected on Form1.

Look up the OpenForm method in VBA help.
 
Top