Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2005
    Posts
    102

    Unanswered: Invalid Use Of Null

    Hi, I have this code that runs when a form is open,

    Code:
        Dim NormalDate As Date      ' The serial date.
        Dim strDateYear As String      ' The year of the serial date.
        Dim strJulianDay As String
        Dim strJulianDate As String    ' The converted Julian date value
        
        'This will lookup the tblTodaysOrder to see whether items exist.
        Dim Lookup As Integer
        Lookup = DLookup("[CountOfBarcode]", "qryCountOfLineItems")
        If Lookup < 1 Then 'if there is/are no item(s) then show message
        MsgBox "There are no items to issue a PO for, cancelling PO Entry....", vbExclamation, "No Items"
        DoCmd.Close acForm, "frmPOEntry"    ' close the form
        Else
        SendKeys "y", False
        SendKeys "y", False
        DoCmd.RunSQL "DELETE tlbPurchaseOrders.* FROM tlbPurchaseOrders;"
        DoCmd.RunSQL "DELETE tblTmpOrders.* FROM tblTmpOrders;"
        DoCmd.OpenForm "frmMainPage", acNormal, "", "", acReadOnly, acHidden
       
        ' NormalDate variable = Today's Date
        NormalDate = Date
        ' Assign DateYear the year number
        DateYear = Format(NormalDate, "yy")
        ' Find the day number for NormalDate
        JulianDay = Format(Str(NormalDate - DateValue("1/1/" & Str(DateYear)) + 1), "000")
        ' Combine the year and day to get the value for JulianDate.
        JulianDate = DateYear & JulianDay
        txtPOSub1 = JulianDate
        
        End If
    When the form opens (if there are items) it is suppose to assign the variable JulianDate to a textbox (txtPOSub1), but rather it gives me this message saying "Invalid Use Of Null".

    However, when I put this same code in a different form

    Code:
        Dim NormalDate As Date      ' The serial date.
        Dim strDateYear As String      ' The year of the serial date.
        Dim strJulianDay As String
        Dim strJulianDate As String    ' The converted Julian date value
        
    ' NormalDate variable = Today's Date
        NormalDate = Date
        ' Assign DateYear the year number
        DateYear = Format(NormalDate, "yy")
        ' Find the day number for NormalDate
        JulianDay = Format(Str(NormalDate - DateValue("1/1/" & Str(DateYear)) + 1), "000")
        ' Combine the year and day to get the value for JulianDate.
        JulianDate = DateYear & JulianDay
        Text1 = JulianDate
    It seem to work okay and gives me today's date (in Text1) in Julian format...
    Any clue on what could be causing this????
    The only true wisdom is in knowing you know nothing.

  2. #2
    Join Date
    Dec 2003
    Location
    Colorado
    Posts
    24
    Have you definitely narrowed the "Invalid Use Of Null" to the textbox?
    Have you confirmed the DLookup is not returning a null value?
    Ray Burrows

  3. #3
    Join Date
    Jun 2005
    Posts
    102
    Quote Originally Posted by xburrows
    Have you definitely narrowed the "Invalid Use Of Null" to the textbox?
    Yes I have.
    Have you confirmed the DLookup is not returning a null value?
    Yes, if DLookup does return a value less than 1 then the form would close itself.

    Also, I mentioned that if I ran the code on another form, it runs without problems, ony on this form. I don't know why.
    The only true wisdom is in knowing you know nothing.

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Have you run a compact and repair yet? debug your values on that line to make sure they're not null too.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  5. #5
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,424
    Provided Answers: 8
    Why not use
    nz(DLookup("[CountOfBarcode]", "qryCountOfLineItems"),0)
    or
    Dcount("[CountOfBarcode]", "qryCountOfLineItems")

    just a question why the

    SendKeys "y", False
    SendKeys "y", False
    Last edited by myle; 01-30-06 at 20:08.
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

Posting Permissions

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