Transfer Data between forms

C

Charlienews

Hi,

I'm not sure if this can be achieved but I am trying to do the following:

I have a button which runs a macro to open a new order with all fields
empty. I want to add some code that will populate the corresponding fields
from the quote e.g. CompanyID, Contact ID, Job Description, Title etc.

I would use the following code to populate the fields:
[Customer] = Forms![Quotes]![Customer]
[JobDescription] = Forms![Quotes]![JobDescription]

What I need ideally is code that will open the form and populate the
relevant fields without the need for the macro. Everytime I use the wizard
when I create the button, it gives me all the orders which is not helpful.

Any suggestions would be great.

Thanks in advance

Charlie
 
A

Arvin Meyer

This will only work for new records with the quote for open:

Set the default value of each text box to the Quotes form value. You can do
it manually, by adding:

= Forms![Quotes]![CustomerID]

etc. to the CompanyID.DefaultValue property, or you can do it in VBA code,
like (aircode):

Sub Form_Current()
If Me.NewRecord = True Then
Me.txtCustomerID = Forms![Quotes]![CustomerID]
' etc
' etc
End If
End Sub
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.accessmvp.com
http://www.mvps.org/access
Co-author: "Access 2010 Solutions", published by Wiley


Charlienews said:
Hi,

I'm not sure if this can be achieved but I am trying to do the following:

I have a button which runs a macro to open a new order with all fields
empty. I want to add some code that will populate the corresponding
fields
from the quote e.g. CompanyID, Contact ID, Job Description, Title etc.

I would use the following code to populate the fields:
[Customer] = Forms![Quotes]![Customer]
[JobDescription] = Forms![Quotes]![JobDescription]

What I need ideally is code that will open the form and populate the
relevant fields without the need for the macro. Everytime I use the
wizard
when I create the button, it gives me all the orders which is not helpful.

Any suggestions would be great.

Thanks in advance

Charlie
 

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