tags:

views:

30

answers:

2

Basically I just need the id of the record on the first form so I can stick it in the foreign key column of the record on the second form. How do I pass this information along? Please ask for clarification in comments if this is not enough information.

+2  A: 

If the first form calls the second form, then you can create a function that has as a parameter the object you want to pass in. Then after form creation, call the function.

Below is some psuedo code to demonstrate the calling of the new form and sending of the needed data.

public sub OnClick() {
  Form2 frm = new Form2
  frm.Initialize( recordId )
  frm.Show
}
JDMX
Well said and good example code
Bentley Davis
This is not VBA. Why assume something other than VBA with an ms-access tag?
Remou
The method in this non-VBA code is suggestive, though. You could design your called form to have a custom property that you could assign. Unfortunately, you could only do so if you don't open it with the acDialog argument, so if you need to pause code while the called form is open, this approach wouldn't work.
David-W-Fenton
This example came out of an Excel project I did in 2000. I remember copying it into Access for another project but do not have that file. Although it may not be what the asker is looking for, it is a valid response.
JDMX
It may be valid somewhere, but not in VBA.
Remou
This is basically what I ended up doing. Slightly different code but the idea is the same.
Daniel Straight
+2  A: 

The OpenForm method of DoCmd has both a where argument and an OpenArgs argument. OpenArgs is likely to suit.

 DoCmd.OpenForm "FormName",,,,,, Me.ID

It is also possible to get the information from an open form.

Remou