Solved

Run-Time Error 94 - Invalid Use of Null

Posted on 2007-11-26
4
1,468 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
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.

688 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