Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invalid Use Of Null Error in RecordSet 1

Status
Not open for further replies.

DBServices

Programmer
Aug 19, 2010
54
US
I have a list box that is used to display info only. I am looping through a recordset and displaying the fields using the add item method, however, one of my variables will be null for some records and have a value for others. I get the "Invalid Use of Null" error when the var is null. I have tried to use the If Not IsNull(variable name) but can't get it to work....Any and all help will be greatly appreciated...
Code:
    Do While Not rsSubItems.EOF
      subItemID = rsSubItems!MenuItemDetailsID
      subItemName = rsSubItems!MenuItemChoiceDescription
      subItemPrep = rsSubItems!PrepName
      lst.AddItem (subItemID & ";" & "-----" & subItemName & ";" & subItemPrep)
      rsSubItems.MoveNext
    Loop
rsItems.MoveNext
the variable "subItemPrep" will sometimes be null so I want it to just not add anything for that...

 
I expect (but can't tell since you haven't shared more of your code) that subItemPrep is dim'd as a string. If so, you can dim it as Variant and check for null or add a zero-length-string to the field.


Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top