Solved

Run-Time Error 94 - Invalid Use of Null

Posted on 2007-11-26
4
1,463 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

Backup Your Microsoft Windows Server®

Backup 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.

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now