Opening new form to New item but passing some specific data
Posted on 2011-02-21
I want to open a form to a new record, but pass some specific data to the form so it is pre filled out. For example
On form A, we have a main form with CustomerCode, CustomerName, and some customer specific details from the tabel CUSTOMERS
On this form is a subform called CustomerNotes. This has CustomerLink (linked to CustomerCode), the Notes_ID (autonumber) and various items from the Customers_Notes table.
From the subform the client can click the Note_ID and goto a viewing screen of that specific note. This works perfectly.
If the client clicks (new) in the Notes_ID then it takes them to a form to enter a new customer Notes record. I have this working too. However, I would like to pre-fill in the CustomerCode this new note relates to so the client does not have to do it, and eliminate mistakes by the client when doing this.
I am struggling with the very last bit, which is entering the customerCode and CustomerName.
I have tried setting CustomerCode to the value on the previous form in the following ways
1. As an Openargs value being sent on the docmd.openform when opening Form B for the value of CustomerCode on form A
2. setting the value in form B to the value in form A on both the OnLoad and onOpen events but can't quite get this to work
My question is what order do events occur ? How can I open the Notes_ID to new record then set customerCode to a specific number, and populate CustomerName based on this CustomerCode, all before the form is visible to the client.
Thanks in advance