Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I assign a value to a field?

Status
Not open for further replies.

ineloquucius

Programmer
Jun 6, 2006
9
US
I want to open an MSACCESS form, go to the "new" record, and copy a value from the previous form to a particular field in the "new" record.

For example: Auto shop invoicing--I open a form "new invoices" and select an existing customer. But the customer is bringing a new vehicle so I click a button activating the form "vehicles", filtered to show this customers vehicles only, and advance directly to the "new" record. No problem so far, but I want the "customer number" field of the "new" record to automatically be assigned the value of the customer number on which I've filtered this list. I've tried starting simply by assigning this field to an absolute as in: "Forms![vehicles]![customer number] = 4" . But this is apparently a nonsense statement on my part. I've substituted periods for !'s and vice versa. How do I perform this VERY SIMPLE field value assignment in Access's visual basic?

Much appreciated
 
neloquucius
I think this should be in when the form opens.

Forms![vehicles]![customer number] = Forms![customer]![customer number]

or use a query for your form then under customer number in the criteria put Forms![customer]![customer number]

I hope this helps.

 
Ignore my post. I read it wrong. The other post is correct. I thought yours said previous RECORD instead of form.
Also, when you implement the first option above, the form must stay open. You can close it when you close the most recent form.
 
ineloquucius,

Another way is to pass the value in the OpenArgs argument of the DoCmd.OpenForm method:
Code:
DoCmd.OpenForm "new invoices", , , , , , Me![customer number]
Then in the new form's Open event:
Code:
Me![customer number] = Me.OpenArgs
HTH,

Ken S.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top