UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Invalid Use Of Null On Date, Office 2002    
 
   
ebwhittaker
post May 6 2012, 10:47 AM
Post #1

UtterAccess Guru
Posts: 724
From: Arcadia, Florida



Dim TranDate as Date

TranDate = [Forms]![ReceivedForm]![DatePaid] and gives me an Invalid Use of Null error if there is nothing in the field, which is possible so I need to get around it by either bypassing or envoking a message that there is no date

Thanks
Ed
Go to the top of the page
 
+
Peter46
post May 6 2012, 10:58 AM
Post #2

UtterAccess VIP
Posts: 7,394
From: Oadby Leics, UK



if isnull([Forms]![ReceivedForm]![DatePaid]) then
msgbox "No date" ' or whatever you want to do here
else
TranDate = [Forms]![ReceivedForm]![DatePaid]
End if
Go to the top of the page
 
+
fkegley
post May 7 2012, 09:33 AM
Post #3

UtterAccess VIP
Posts: 23,583
From: Mississippi



Or you could not specify a data type. In that case, Access will treat it as a type Variant, which can contain a Null.

Then you would test for the null value, converting it to some impossible value, otherwise using it as a date.

For instance,

If IsNull(VariableName) Then
DateValue = CDate(0) ' or some other impossible vallue
Else
If IsDate(VariableName) Then
DateValue =VariableName
End If
End If
Go to the top of the page
 
+
ebwhittaker
post May 7 2012, 09:39 AM
Post #4

UtterAccess Guru
Posts: 724
From: Arcadia, Florida



Thanks all ... as usual it worked perfectly

Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 19th May 2013 - 11:46 AM