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 bkrike 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

Status
Not open for further replies.

kcmark

Technical User
Nov 2, 2002
63
US
I have a data entry form that uses a combo box as one of the input fields. When the user selects the item from the drop down list everything works fine.

When the user types the first letter of the item (to avoid using the drop down list) the name correctly displays as if they had selected it from the drop down list. However, I get an error that says " Runtime Error 94 - Invalid Use of Null Error"

I am passing the data in this field to a DLookup function which is where the error is generated. I only get the error when they use they type the first letter and never when they select from the menu. Any ideas?
 
I get an error that says " Runtime Error 94 - Invalid Use of Null Error"
Any chance you could say us where this error is raised and what is the highlihted code when you enter debug ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
The value from the drop down list is passed to a Dlookup command using an OnChange event. Here is the specific line of code that is causing the error.

SR1_Rate1 = DLookup("[SW_Rate]", "[Sales Rep]", "[Rep_Name] = " & Chr(34) & Me![SR1] & Chr(34))

I think what is happening is that only the actual letters I typed (and not the entire value from the drop down list) are being passed to the Dlookup command - And the dlookup is returning a null response because it needs the entire value from the drop-down list to work. This would explain why I only get this error when I type and never get the error when I select the item from the list. What is confusing to me is that the entire name appears as soon as a match is found (because I use the AutoExpand property).

 
OnChange event
Place your code in the AfterUpdate event procedure of the combo instead of the Change event.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top