Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Join Date
    May 2007
    Posts
    74

    Unanswered: 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

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Are you passing a value when you open the form?
    Paul

  3. #3
    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

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    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

  5. #5
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    What is parseOpenArgs (Me.OpenArgs) supposed to do?
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  6. #6
    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

  7. #7
    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.

  8. #8
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    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

  9. #9
    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

  10. #10
    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

  11. #11
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    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 problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  12. #12
    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

  13. #13
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    You might try a decompile on a COPY and see if it helps:

    http://www.granite.ab.ca/access/decompile.htm
    Paul

  14. #14
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    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

  15. #15
    Join Date
    Oct 2011
    Posts
    1

    Unhappy 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...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •