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

Passing Parameters To An Open Form

Status
Not open for further replies.

bdjc

Technical User
Nov 6, 2001
4
I have form A and form B. I want to pass a parameter or argument from form A to form B. Form B may or may not be open at the time form A opens form B. When form A opens form B I use the openargs option on the following command docmd.openfrom,,,,,, "recordid". If form B is not open at the time form A initiates the opening of form B, the openarg works great. The problem occurs when form B is already open when form A opens form B. In this scenario the openargs data is equal to what it was when the form originally opened. Is there a way to pass a parameter to a form that is currently opened?

Thanks for your help
bdjc
 
As usual there are a number of ways of skinning the cat .. ..

You could consider:-
Before Opening FormB, check to see if FormB is already open. If it is the Close it brfore running the DoCmd.OpenForm command.

Alternatively, Simply get FormA to write to a control on FormB.
Eg. If control on FormB is "txtNewDataHere" then

On Error GoTo ErrorCatcher
FormB!txtNewDataHere = RecordId

' Then in ErrorCatcher
ErrorCatcher:
If Err.Number = xxxx Then
DoCmd.OpenForm, , , , , , RecordId
Resume Next
Else
etc.. ..


A Third option might work if FormA is always open when FormB is open
Just get the control on FormB to refer to the control on FormA containing the RecordId.
Eg txtNewDataHere.CountrolSource = FormA!txtRecordId
where txtRecordId is the name of the control containing the RecordId data.



'ope-that-'elps.

G LS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top