none
run-time error '94' invalid use of null - under Access 2013 RRS feed

  • Question

  • I have this error after add two new month for recent for month forecasting.

    after i click debug, the below showed up:

    Private Sub Form_Load()
        ' Dim rsPeriod As DAO.Recordset
        ' Set rsPeriod = CurrentDb.OpenRecordset("Perioddate")
        ' Me.Period_Date = Me.Period_Date.(0)
       Set_global_variable_strPeriodLA "'" & Me.Period_Date.ItemData(0) & "'"
       Set_global_variable_strPeriod "'" & Me.Period_Date.Column(0) & "'"
       strCurPeriod = Me.Period_Date.ItemData(0)
       strPrevPeriod = Me.Period_Date.ItemData(1)
     'Set rs = CurrentDb.OpenRecordset(s)

    the sentence: strCurPeriod = Me.Period_Date.ItemData(0)  is in hightlight yellow.

    what should i do to solve the error?

    Much appreciated!

    Friday, October 27, 2017 4:58 PM

All replies

  • Hi Stella,

    Based on the error message, I am guessing the value of Me.Period_Date.ItemData(0) is Null, which means nothing was selected by the user. If so, you can either check for it first or use the Nz() function to assign a default value when it is empty or Null.

    Hope it helps...

    Friday, October 27, 2017 7:50 PM
  • Hi Stella_G,

    I can see that you comment some lines.

    ' Dim rsPeriod As DAO.Recordset
         ' Set rsPeriod = CurrentDb.OpenRecordset("Perioddate")
         ' Me.Period_Date = Me.Period_Date.(0)

    I cannot find the code , how you assign the value to "Me.Period_Date.ItemData(0)".

    if this is not a complete code then I suggest you to post the complete code.

    also you can try to debug the code and check the value of "Me.Period_Date.ItemData(0)".

    hover the mouse over it and check it's value.

    you can also print the value in immediate window to verify the same.

    As  .theDBguy suggested you it is possible that "Me.Period_Date.ItemData(0)" does not contain any value.

    that cause this error.

    so try to check it and let us know about the result.

    we will try to provide you further suggestion, if needed.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, October 30, 2017 9:20 AM
    Moderator