Solved

Run-Time Error 94 - Invalid Use of Null

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
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.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

828 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