Open a form and pass a parameter

  • Thread starter Thread starter Alan T
  • Start date Start date
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.
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top