Solved

Run-Time Error 94 - Invalid Use of Null

Posted on 2007-11-26
4
1,465 Views
Last Modified: 2013-11-28
I created a text box (txtText) and pasted this function in the Control Source:
=GetTestType(Nz([cboTestType]). This text field is used only for display purposes.

When user selects an item from cboTestType, the item selected is displayed both in the combo and the textbox (txtTest).

Problem:
How do I correct this Run-Time error 94?
When user selects an item from a cboTestType, user gets: Run-Time error 94 - "Invalid use of Null"

.......on...
GetTestType = DLookup("TestType", "tblTest", "TestlID='" & myPID & "'")

...from the function below:

Public Function GetTestType(myPID As String) As String
If Len(myPID) < 2 Then
GetTestType = "" ' or whatever you want to dislpay in this case
Else
GetTestType = DLookup("TestType", "tblTest", "TestlID='" & myPID & "'")  '<<== Error line
End If
End Function
0
Comment
Question by:billcute
  • 2
  • 2
4 Comments
 
LVL 46

Accepted Solution

by:
tbsgadi earned 500 total points
ID: 20348918
Hi billcute,

GetTestType = nz(DLookup("TestType", "tblTest", "TestlID='" & myPID & "'"))

Good Luck!

Gary
0
 
LVL 4

Author Comment

by:billcute
ID: 20349016
tbsgadi:
Could you please provide an explanation why "nz" was placed before "DLookup"?
The same function worked for me in other texttype boxes.

Regards
Bill
0
 
LVL 4

Author Comment

by:billcute
ID: 20349119
tbsgadi:
Is there any way I can let you know of my future posts?
Regards
Bill
0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 20349150
The nz turns nulls into "".
You probably didn't have nulls before.
If I'm online I'll see your posts
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question