Originally Posted by
Nokia N93
i have two forms , and one table
i want when i enter the first form and press Next or Submit, i want specific values to be passed to the next form (example ID, name, and address)
i knew there is something called OpenArgs but i didn't know how to apply it, i also read it is just for one value
There are several ways to accomplish what you want to do. So here is the setup;
There is one table, "Table1", and two forms, "Form_A" and FormB" (notice - no spaces). At this point I have to wonder "Why two forms?". The data is stored in Table1, so one form could display the data.
Moving on..
Method 1: referring to controls on a previous form (as Adam posted).
Method 2: Use the "WhereCondition" argument of the "OpenForm" method. (IMO,the easiest method)
If the "ID" field type is a number, the command would look like"
Code:
DoCmd.OpenForm "FormB", , ,"ID = " & Me.tbID
(tb=text box)
This would open the form "FormB" to the first record that equaled the number in the control "tbID" on form "Form_A". The (new) record on "Form_A" must be saved first.
Method 3: Use OpenArgs
This takes some coding. And you can pass more than one value, but it requires code. The command would look like:
Code:
DoCmd.OpenForm "FormB",,,,,, Me.tbID & ", " & Me.tbFullName & ", " & NZ(Me.tbAddress,"")
(I used "FullName because "Name" is a reserved word in Access.) If a control value is or could be NULL, you would need to use the NZ() function to avoid passing a null value.
In the form open event of "FormB", you use the split command to separate the values. Since the values would be in an array, loop thru the array, assigning the values to the proper controls.