On Load error msg and Open Args

Posted on 2012-08-21
Last Modified: 2012-08-21
Experts, when I open this form on its own (meaning Open Args is Null) I get an error msg and the debugger highlights the bolded below.  How can I avoid this?  I thougth that the first If statement takes care of it.

Private Sub Form_Load()

        If Nz(Me.OpenArgs, "") <> "" Then
       Me.Filter = "[PrjID] = " & Split(Me.OpenArgs, ";")(0) ' & " AND [EndUserID] = " & Split(Me.OpenArgs, ";")(1) & " AND [LCNo] = " & Chr(34) & Split(Me.OpenArgs, ";")(2) & Chr(34)
       Me.FilterOn = True
              Me.PrjID = Split(Me.OpenArgs, ";")(0)             End If

End Sub
Question by:pdvsa
    LVL 119

    Accepted Solution

    you have to remove this line

    Me.PrjID = Split(Me.OpenArgs, ";")(0)    

    that line is setting the value for for your PrjID from a NULL source
    LVL 47

    Expert Comment

    by:Dale Fye (Access MVP)
    Personally, I would test for OpenArgs is NULL, and if so, exit the sub:

     If IsNull(me.OpenArgs) Then Exit Sub

     Me.Filter = "[PrjID] = " & Split(Me.OpenArgs, ";")(0) & " AND " _
                    & "[EndUserID] = " & Split(Me.OpenArgs, ";")(1) & " AND " _
                    & "[LCNo] = " & Chr(34) & Split(Me.OpenArgs, ";")(2) & Chr(34)
    Me.FilterOn = True

    Author Closing Comment

    thank you sir...

    thanks for the comment fyed.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Suggested Solutions

    When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
    Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now