OpenArgs lifespan (2 Viewers)

Zydeceltico

Registered User.
Local time
Today, 07:19
Joined
Dec 5, 2017
Messages
843
If I use OpenArgs to pass data from Form1 to Form2, is the value in openArgs cleared after it is used or do I need to clear it some how to use another OpenArgs statement to open Form3 from Form2 while Form1 is still open underneath Form2?

Thanks!

Tim
 
Hi Tim. The value in the OpenArgs property stays until you change it (by opening the form again) or the form is closed.
 
Hi Tim. The value in the OpenArgs property stays until you change it (by opening the form again) or the form is closed.

I take that to mean then that when I use OpenArgs when opening Form3 from Form2 that it will then overwrite/replace the OpenArgs I used to open Form2 from Form1.
 
I take that to mean then that when I use OpenArgs when opening Form3 from Form2 that it will then overwrite/replace the OpenArgs I used to open Form2 from Form1.
Well, I thought so, but doing a quick test appears the OpenArgs is stuck. It stays until the form is closed. So, if you want to change it, it seems you'll have to close and reopen the form.
 
I take that to mean then that when I use OpenArgs when opening Form3 from Form2 that it will then overwrite/replace the OpenArgs I used to open Form2 from Form1.

I read that, as each form has it's OWN OpenArgs as it it a property of each form?
 
I read that, as each form has it's OWN OpenArgs as it it a property of each form?

I read the same but DB is saying his test is not resulting in that behavior.

Something to play with tonight and keep me up for hours. :-)
 
I read the same but DB is saying his test is not resulting in that behavior.

Something to play with tonight and keep me up for hours. :-)
Of course, you don't have to take my word for it. You can perform your own tests and let us know your findings. I am always happy to learn new things. Cheers!
 
Of course, you don't have to take my word for it. You can perform your own tests and let us know your findings. I am always happy to learn new things. Cheers!

LOL - and I shall!! :-)

Thanks!
 
We shall await the results. Please keep us posted.
 
Just think of it as a little service for mankind. ;)
 
It is an easy test and it is unique property to each form. It can only be set through the openform method and is read only.
CODE]Public Sub TestArgs()
DoCmd.OpenForm "form1", , , , , , "Hello World"
MsgBox Forms("form1").OpenArgs
DoCmd.OpenForm "form2", , , , , , "Goodbye World"
MsgBox Forms("form2").OpenArgs
End Sub[/CODE]
I get 2 messages with the correct args

Well, I thought so, but doing a quick test appears the OpenArgs is stuck. It stays until the form is closed.
Curious how you tested. We may be talking two different things.
 
It is an easy test and it is unique property to each form. It can only be set through the openform method and is read only.
CODE]Public Sub TestArgs()
DoCmd.OpenForm "form1", , , , , , "Hello World"
MsgBox Forms("form1").OpenArgs
DoCmd.OpenForm "form2", , , , , , "Goodbye World"
MsgBox Forms("form2").OpenArgs
End Sub[/CODE]
I get 2 messages with the correct args


Curious how you tested. We may be talking two different things.
Fair question. The way I understood the OP's requirements is to have two separate forms open the same one while passing which form opened it through the OpenArgs argument. So, in my test, I created three forms: Form1, Form2, and Form3. I created a button in forms Form1 and Form2 to open Form3. So, from Form1, I opened Form3 and passed "Form1" as OpenArgs. Then, from Form2, I opened Form3 again (remember, it was still open from Form1) and pass "Form2" as OpenArgs. However, executing ?Forms!Form3.OpenArgs from the Immediate Windows still revealed OpenArgs as "Form1" instead of "Form2." Hope it makes sense...
 
That leads me to ask...

What happens if you were to open the same form multiple times? passing a CustID for instance as OpenArgs? instead of a WHERE clause?
 
Last edited:
That leads me to ask...

What happens if you were to open the same form multiple times? passing a CustID for instance as OpenArgs? imstead os a WHERE clause?
Hi. That's exactly what I described I did in my small test. Did you get a different set of results?
 
Hi. That's exactly what I described I did in my small test. Did you get a different set of results?

No, I was just curious as it is not something I have needed to do, but wondered how you would determine which form was which?

Might have a go tomorrow to see what actually happens.:)
 
No, I was just curious as it is not something I have needed to do, but wondered how you would determine which form was which?

Might have a go tomorrow to see what actually happens.:)
In this case, if you want to keep the form open between other forms, it seems you'll have to use a different place for identifying the opening form because it appears you can't use OpenArgs (reliably).
 
The open wanted to leap from 1 opens 2 and 2 opens 3.
The result you got made sense because when you open an open form it does not "reopen" it just gets the focus.

Easy test in Form1

Private Sub Form_Open(Cancel As Integer)
MsgBox "Open"
End Sub

You can Docmd.Openform multiple times and it will only occur once.

Another test

Code:
Public Sub Testreopen()
  DoCmd.OpenForm "form1"
  MsgBox "not dialog"
  DoCmd.OpenForm "form1", , , , , acDialog
  MsgBox "still not dialog"
End Sub
 
Found this on Allen Browne site, but it appears you are not able to use OpenArgs anyway.

http://allenbrowne.com/ser-35.html

However he does not address, how you would switch to any of them in code, should you need to.?
 

Users who are viewing this thread

Back
Top Bottom