| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |
|

07-13-07, 20:43
|
|
Registered User
|
|
Join Date: May 2007
Posts: 74
|
|
|
OpenArgs is always Null?
|
|
I am opening a form from a separate module, and the "Me.OpenArgs" value is always Null in the OnOpen event for the form.
I'm probably missing something basic here, but I didn't easily find anything about this in the dbforums archive.
Any ideas?
__________________
AzJazz
"I'm afraid the holodeck will be society's last invention." - Scott Adams
|
|

07-13-07, 21:50
|
|
Registered User
|
|
Join Date: May 2005
Location: Nevada, USA
Posts: 2,400
|
|
Are you passing a value when you open the form?
__________________
Paul
|
|

07-16-07, 14:30
|
|
Registered User
|
|
Join Date: May 2007
Posts: 74
|
|
|
|
Yes, I have a string value being sent to the OpenArgs parameter of my DoCmd.OpenForm.
I checked, and that value is populated when the call is made, but the OnOpen for the Form shows the Me.OpenArgs value as Null.
Here's the call:
Code:
Public Sub openDialog(formName As String, Optional fieldName As String)
locFormName = formName
locFieldName = IIf(IsMissing(fieldName), "", fieldName)
DoCmd.OpenForm "FRM_Find", , , , , , locFormName
End Sub
Note: locFormName and locFieldName are local module-level variables that are Strings.
Here's the OnOpen event for the "FRM_Find" form:
Code:
Private Sub Form_Open(Cancel As Integer)
If Not IsNull(Me.OpenArgs) Then parseOpenArgs (Me.OpenArgs)
End Sub
__________________
AzJazz
"I'm afraid the holodeck will be society's last invention." - Scott Adams
|
|

07-16-07, 14:40
|
|
Registered User
|
|
Join Date: May 2005
Location: Nevada, USA
Posts: 2,400
|
|
That actually looks okay, offhand. I thought it might be the open event, but a quick test confirms that's okay. Can you post a sample with those 2 forms?
__________________
Paul
|
|

07-16-07, 14:55
|
|
Registered User
|
|
Join Date: Jun 2005
Location: Richmond, Virginia USA
Posts: 1,559
|
|
What is parseOpenArgs (Me.OpenArgs) supposed to do?
__________________
Hope this helps!
The Missinglinq
There's always more than one way to skin a cat!
All posts/responses based on Access 2000/2003
|
|

07-16-07, 15:18
|
|
Registered User
|
|
Join Date: May 2007
Posts: 74
|
|
Quote:
|
Originally Posted by pbaldy
That actually looks okay, offhand. I thought it might be the open event, but a quick test confirms that's okay. Can you post a sample with those 2 forms?
|
I can try, but I've never sent a form to the forum. Do I export it & zip it somehow?
Quote:
|
Originally Posted by Missinglinq
What is parseOpenArgs (Me.OpenArgs) supposed to do?
|
It's actually a blank sub right now. Since I wanted to send multiple arguments to the form, I was planning on inserting a "Ctrl-F" at the end of each sub-string/argument, and then parsing out the strings in the parseOpenArgs sub. I don't think that OpenArgs can handle string arrays.
__________________
AzJazz
"I'm afraid the holodeck will be society's last invention." - Scott Adams
|
|

07-16-07, 15:30
|
|
Registered User
|
|
Join Date: Feb 2004
Location: Chicago, IL
Posts: 1,312
|
|
Do you have Option Explicit at the top of your modules? I don't see a typo in the code you posted but it might be somewhere.
|
|

07-16-07, 15:30
|
|
Registered User
|
|
Join Date: May 2005
Location: Nevada, USA
Posts: 2,400
|
|
You could export the necessary objects to a blank db, then zip and attach that here. You just need whatever objects will recreate the problem.
The typical way I've heard of handling multiple values in OpenArgs is putting some sort of delimiter in between values (like ";"), then parsing it back out at the other end.
__________________
Paul
|
|

07-16-07, 18:33
|
|
Registered User
|
|
Join Date: May 2007
Posts: 74
|
|
Well, isn't this fun!
I have found bizarre, unexplainable behavior with Access in the past, and now I have a new item to add to the list.
Previously, I was using the built-in VBA debugger to check the values that were being seen by the various routines. I would put my cursor over a variable to see the tooltip that showed that variable's value.
I was creating an example database for you guys to check out, and accidentally "fixed" the problem.
When I added a quick MsgBox to the routine that contained the DoCmd.OpenForm, the problem went away! Even after I deleted the MsgBox line (so my code was identical to the "problem" code), the problem was now gone.
Well, at least it's working now!
__________________
AzJazz
"I'm afraid the holodeck will be society's last invention." - Scott Adams
|
|

07-16-07, 19:03
|
|
Registered User
|
|
Join Date: May 2007
Posts: 74
|
|
Quote:
|
Originally Posted by azjazz
I have found bizarre, unexplainable behavior with Access in the past, and now I have a new item to add to the list.
|
I was wrong - It isn't fixed yet, and I'm trying to build a database to show the problems.
Stay tuned ...
__________________
AzJazz
"I'm afraid the holodeck will be society's last invention." - Scott Adams
|
|

07-16-07, 19:24
|
|
Registered User
|
|
Join Date: Jun 2005
Location: Richmond, Virginia USA
Posts: 1,559
|
|
Don't you just hate it when that happens? Here's a site that has a function for passing multiple values, using the general idea Paul mentioned:
http://www.codeproject.com/vb/net/pa...select=1730847
__________________
Hope this helps!
The Missinglinq
There's always more than one way to skin a cat!
All posts/responses based on Access 2000/2003
|
|

07-16-07, 19:58
|
|
Registered User
|
|
Join Date: May 2007
Posts: 74
|
|
Quote:
|
Originally Posted by Missinglinq
Don't you just hate it when that happens?
|
Yeah, this is driving me nutz. I can't seem to reliably create the problem. When the problem occurs in the demo database and I save it, it doesn't always occur when I re-open the same database.
Also, if I comment-out an unrelated line of code, the problem may become visible (at least, until the change gets saved).
The original database shows the problem, but I can't forward that onto y'all. And, if I delete unrelated items from the database, it can make the problem go away.
This has me concerned that my Access project is going to be very unstable from this point forward, and since the main users are my bosses who determine if I stay employed, I'm not very happy.
PS: Thanks for the link!
__________________
AzJazz
"I'm afraid the holodeck will be society's last invention." - Scott Adams
|
|

07-16-07, 20:02
|
|
Registered User
|
|
Join Date: May 2005
Location: Nevada, USA
Posts: 2,400
|
|
|
|

07-17-07, 11:54
|
|
Registered User
|
|
Join Date: May 2004
Location: New York State
Posts: 880
|
|
In my experience, OpenArgs has to be handled immediately upon opening of the form. To my mind, that's why the MsgBox made the problem go away. What you may want to do is dimension a global string variable, maybe called txtFormName, in the form. In the first line of the form's Open event, you can have code like
Code:
txtFormName = Me.OpenArgs
Then you can do whatever you need to before actually using that form name; you already captured the OpenArgs.
HTH,
Sam
|
|

10-14-11, 05:56
|
|
Registered User
|
|
Join Date: Oct 2011
Posts: 1
|
|
Nothing works
All of the suggestions, code and so on do not seem to work to simply pass data into a modal form.
I have to say after 6 months of full time Access program, I would do anything to go back to WPF and Win Forms. I could work 10 times faster and get a much better result. WinForms VB.NET is way easier to program and maintain than access. My suggestion for Access, is that if you need VBA code to make your app work, then move your project to .NET... You'll save time...
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|