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!

Openargs use on loaded form

Status
Not open for further replies.

dabruins

Programmer
Mar 9, 2005
102
CA
I am attempting to add a quick query tool to an unbound form (Form1). By pressing a command button on Form1 the user would open a smaller form (Form2) containing two textboxes and a command button. After providing data for a query and pressing the command button on Form2 a query would be run to find a valid record Id that would be passed as an OpenArgs parameter in a DoCmd.Open call for Form1. I'm finding that the OpenArgs value is not being read. Does the OpenArgs parameter get recognized if the form being opened is already loaded?

Maybe I'm going about this the wrong way? Any ideas?
 
If Form1 is open and then somewhere else you use a
DoCmd.OpenForm "Form1"

then all that happens is that Form1 is given the focus.

It does NOT open a new instance of Form1.


Could I suggest that you use a global variable or this job.
Create a module ( I call mine mdlDeclares ) and in it define a Public variable eg
Public glngForm1Id As Long

Then in the line before your DoCmd.OpenForm you just set glngForm1Id to the value that it needs to be.
Inside Form1 you just use glngForm1Id in all the places you currently use OpenArgs

Note OpenArgs is NULL if not set
glngForm1Id cannot be Null as it is a Long data type.
So set it to 0 to indicate 'no value' and test for =0 rather than IsNull if appropriate.


'ope-that-'elps.


G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
Yes, I had been thinking that the Open command would not be treated the same way if the form is loaded. I just wanted someone to confirm my observations.

Thanks for the idea of using a public variable. I had been considering it but still wanted to know how the OpenArgs worked in this case. Thanks for your help LittleSmudge!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top