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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing parameters between forms

Status
Not open for further replies.

croydon

Programmer
Apr 30, 2002
253
EU
I'm a bit rusty with Access, but have an application to modify.

I have two forms. One is unbound (form1) and has just a listbox (with a record key and description from table1) and a button.

The other form (form2) is bound to table1 and has a textbox for each column of the table.

On the first form, I want the user to select a record from the listbox and click on the button, then the record to appear in detail on form2.

My question is: what is the normal way of passing the record key between forms to display the record on form2?

Any suggestions would be appreciated. Thanks.
 
The last parameter of the DoCmd.OpenForm method is the OpenArgs parameter. You can pass whatever you need to the second form, and you can access the OpenArgs in the OnOpen event of the second form.

Or, you could also use the WhereCondition parameter of the DoCmd.OpenForm method to filter your second form.
 
rjoubert, thanks for the reply.

As Tek-Tips wasn't available to the UK this morning, I had to find another way of doing it.

The method I came up with was that form1 opens form2 and in the page_load event updates the filter with a reference to the form1.list1.value.

On form2, other than the bound textboxes there is only a button to save the record. This was created with the button wizard. There is no other code other than the button_click and page_load.

Strangely, some of the time this worked ok but other times I received "Write Conflict" errors although I was the only user in this database.

The backend database is SQL Server 2005. Are any additional parameters required in Access VBA for this?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top