Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2010
    Location
    UK
    Posts
    160

    Unanswered: If IsNull code not working as planned

    hi all,

    Does anyone see anything wrong with the code below? For some reason it never executes when txtRecountCount is null and always runs the else section.



    If IsNull([Forms]![Main_Sub_Items]![frm_Main_sub_system].Form![txtRecordCount]) Then

    MsgBox ("Null code executed")
    Record_Counter = 1
    Else


    Record_Counter = (Forms![Main_Sub_Items]![frm_Main_sub_system].Form![txtRecordCount]) + 1

    End If

    thanks again
    Marcus

  2. #2
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    496
    Provided Answers: 24
    Check the value of ([Forms]![Main_Sub_Items]![frm_Main_sub_system].Form![txtRecordCount]
    in the immediate window (Ctrl-G) by using the question mark:
    ? ([Forms]![Main_Sub_Items]![frm_Main_sub_system].Form![txtRecordCount]

    It may not be null, it could be "".

  3. #3
    Join Date
    Sep 2010
    Location
    UK
    Posts
    160
    hi ranman256,

    I just tried using the Intermediate window and i get an error 2427 "You entered an expression that has no value"

    I've tried checking for "" IsEmpty IsNothing IsNull but none of them seem to work. It doesnt like the fact that i'm checking the value of an unbound textbox which displays the number of records when there are no records to count. If i force at least one record in the table then the code works fine. It's just that initial state of no records it does not like :-(

    thanks
    Marcus

Posting Permissions

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