If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > MS Access 2007, Working with Null Values

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-05-12, 16:22
dhartwig35805 dhartwig35805 is offline
Registered User
 
Join Date: Aug 2010
Location: Huntsville, Alabama
Posts: 11
Question MS Access 2007, Working with Null Values

ALCON,

I am generating an application in Access and I am checking for the presence of data within a field on a form. If no data, flag it as an error. In my trusty Access 2007 Bible, for a String variable, the minimum value is 0 (zero) characters. However, if they try to generate a new record, I get a Run-Time '94' error, "Invalid use of Null".

The line of code that generates the error is as follows:
dim secitemdesc as string 'this is the variable declaration

secitemdesc = Me.SECOND_ITEM_SUPPORT_DESC.Value 'error here

I guess that 0 characters is not the same as a Null value for VBA, correct?

Is the best way around this to set the table up so new records give this Control (SECOND_ITEM_SUPPORT_DESC) a default value?

Or is there a different way to deal with null values and variables in VBA?

Any assistance would be greatly appreciated, thank you.

DH
Reply With Quote
  #2 (permalink)  
Old 01-05-12, 16:30
Sinndho Sinndho is offline
Registered User
 
Join Date: Mar 2009
Posts: 3,446
Try:
Code:
secitemdesc = Nz(Me.SECOND_ITEM_SUPPORT_DESC.Value, "")
__________________
Have a nice day!
Reply With Quote
  #3 (permalink)  
Old 01-05-12, 16:41
dhartwig35805 dhartwig35805 is offline
Registered User
 
Join Date: Aug 2010
Location: Huntsville, Alabama
Posts: 11
Thumbs up Yo-Ho-Ho & Bottle of Rum!!

Hey,

That worked great, thanks very much. Such a simple fix, too bad I am a financial analyst and not a VBA programmer. But I am learning quite a bit and I cannot thank you enough for your help. It'll keep my boss off of my back for a few more days, so that is a good thing.

Thanks again.

DH
Reply With Quote
  #4 (permalink)  
Old 01-05-12, 16:42
Sinndho Sinndho is offline
Registered User
 
Join Date: Mar 2009
Posts: 3,446
You're welcome!
__________________
Have a nice day!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On