From a form control, open another form relating to that record

G

Guest

In our Job Control system I have a Customers table that stores all the usual
info about each company, and a corresponding form ("CorporateDataForm") where
this data is maintained.

On the Billing form for each job record there is a control (a combo) showing
the name of the Customer for that particular job.

Next to this I would like to place a command button that opens the
CorporateDataForm for that customer (i.e. the customer on the current record).

I have created the played around with some code behind the OnClick event for
the button including using Me. but cannot get it to work... can some kind
person please tell me exactly how this should be coded???

Thanks a lot!
CW
 
G

Guest

Try:

Docmd.OpenForm "NameOfYourForm"

--
HTH

Mr B
email if needed to:
draccess at askdoctoraccess dot com
 
G

Guest

Thanks, but that just opens an empty Corporate Data Form.
What I need is to open the form relating to the Company that is shown in the
control on the current customer record.
For example: the Jobs form is currently showing the job for Mr Smith. The
Company control on Mr Smith's job is showing XYZ Inc. I want to open the
Corporate Data Form for XYZ Inc.
Thanks again
CW
 
G

Guest

You'll need to add a "where" perameter to the statement.

Take a look in the Access help file for OpenForm to get the correct syntax.

The name of the field and the value you want to see will be based on the
value is being strored in your combo box.

For example, if your combo box returns the actual Customer name then you can
use:
Docmd.openform "NameOFYourForm" , , , "NameOfCustomerNameField =
Me.NameOfYourComboBox"

Watch out for line wraping with the code above.
 
G

Guest

This may be a bit elementary, but when I first started doing this in my forms
(I do it quite often), I used the command button on the toolbox. The wizard
that opens walks you through how to find a related record in the form you are
opening. At first I found that easier until I started to learn more about
writing my own code. Maybe that will work for you as well.
 

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

Top