473,383 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Dim'ing a var as Long, then assigning it to an expression that eval's to #NULL# - Is that a problem?

MLH
Tell me if this assignment should return "Invalid use of Null" error:

Dim RememberedReportNum AS Long
RememberedReportNum = DLookup("[CredReptID]", "[tblCreditReports]")
While considering your response, here's what the DLookUp returns:
? DLookup("[CredReptID]", "[tblCreditReports]")
#NULL#
Can RememberedReportNum not receive the value of #NULL# ?
Nov 13 '05 #1
4 1412
it shouldn't be able to. Null is not a number. It's not a zero. It
means "value unknown".

If you have to be able to assign a null value to a variable, then
declare it a variant, not a long.

Nov 13 '05 #2
"MLH" wrote in message:
news:hb********************************@4ax.com...
Tell me if this assignment should return "Invalid use of Null" error:

Dim RememberedReportNum AS Long
RememberedReportNum = DLookup("[CredReptID]", "[tblCreditReports]")

While considering your response, here's what the DLookUp returns:
? DLookup("[CredReptID]", "[tblCreditReports]")
#NULL#

Can RememberedReportNum not receive the value of #NULL# ?


Only Variant data types can handle Null values.

Consider this example behind a command button for illustration:

Private Sub Command0_Click()

Dim RememberedReportNum As Long
RememberedReportNum = DLookup("[CredReptID]", "[tblCreditReports]")

If IsNull(RememberedReportNum) = True Then
MsgBox "It is Null"
Else
MsgBox RememberedReportNum
End If

End Sub

Pressing the button will yield Error 94, Invalid use of null.

Now change it to a Variant and see what happens:

Private Sub Command0_Click()

Dim RememberedReportNum As Variant
RememberedReportNum = DLookup("[CredReptID]", "[tblCreditReports]")

If IsNull(RememberedReportNum) = True Then
MsgBox "It is Null"
Else
MsgBox RememberedReportNum
End If

End Sub

This time the message box saying it is null appears.
--
Jeff Conrad
Access Junkie
Bend, Oregon

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Nov 13 '05 #3
MLH wrote:
Tell me if this assignment should return "Invalid use of Null" error:

Dim RememberedReportNum AS Long
RememberedReportNum = DLookup("[CredReptID]", "[tblCreditReports]")
While considering your response, here's what the DLookUp returns:
? DLookup("[CredReptID]", "[tblCreditReports]")
#NULL#
Can RememberedReportNum not receive the value of #NULL# ?


Yes.
? NZ(DLookup("[CredReptID]", "[tblCreditReports]"),0)
Nov 13 '05 #4
MLH
Thx 2 U all for your comments.
I'm hip now to the Variant. I'll
take care of it.

Warmest regards.
Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Alain. | last post by:
Dear group, here is my problem In the code of a form, i want to declare a variable : Dim Base_Photo as Database, But Access 2000 don't propose "Database" and don't accept it. But, in an...
13
by: Zeng | last post by:
Hello, Please help!!! I've been stuck on this issue for months. I just wonder if there is a way to programmatically evaluate expression strings such as ( ( 3 + 5 ) / 2 ) > 4 --> this...
1
by: Jason | last post by:
First off, I tried to find an ADO.NET forum, or even just a .NET framework forum but couldn't seem to locate one and I apologize in advance if I've posted in the wrong place. Because I'm using a...
12
by: Wolfgang Kaml | last post by:
Dear all, I am using the following code to retrieve the size of a certain file and the available (free) space on the disk. The problem is, that I get the size of the file returned as a Long and...
5
by: Gary Shell | last post by:
I have two forms both derived by inheriting the same base form. I have a third form that needs to instantiate one of those two forms, set some Protected properties on the two forms, display the...
8
by: Daniel R. Rossnagel | last post by:
Sample: String c="1+2+3" since it can makes to obtain the value of this Expression? Other Sample: Int X=4 String c="1+2+3+X "
22
by: Vijay | last post by:
With the option strict On set..... Dim fs As FileStream = File.OpenRead(strFile) With fs Dim buffer(fs.Length) As Byte ' <--- Option Strict On disallows implicit conversions from 'Long' to...
0
by: Yester | last post by:
I am using the function below to copy values in a field until it reaches the following a value that is <> null...it works fine(see vba below), however I need to accomplish a similar task to copy the...
0
by: John | last post by:
Hi I have written a function to split a string into sub strings of a given fixed max length. This is useful for example in breaking a long message into multiple strings of up to 160 characters...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.