Click to See Complete Forum and Search --> : Null Dates
cruella69
June 23rd, 2000, 09:18 AM
I am reading an Access Database and printing records in VB. In some records the date may be blank and this is OK, for example "date shipped", not all orders are shipped yet. When I try to do ANYTHING with the date, i.e. move to a variable, if the date is Null, I get an error. So I test the date to see if there is anything in it. If there isn't I want to make it 0. But when I print it I get 12/30/99. If I date has nothing in it, how can I print it as nothing. It's not on a line by itself, there are several other fields, so it's difficult to not print it if it's blank.
Thanks
cruella69
Iouri
June 23rd, 2000, 09:33 AM
In your SQL select statement which eliminate records with Null dates
Select * from YourTable where IsDate(DateShipped) = True
Iouri Boutchkine
iboutchkine@hotmail.com
cruella69
June 23rd, 2000, 11:07 AM
The thing is that I want to print the record and show the other things like ordered date and show a blank shipped date
cruella69
Iouri
June 23rd, 2000, 11:32 AM
In this case select all the required records in your SQL. But when you print records check if record is null. For example
If IsNull(Recordset!ShipDate) then
Printer.Print ""
Else
Printer.Print Recordset!ShipDate
End If
Try this if with IsNull and with IsDate, which will suit you better
Good luck
Iouri Boutchkine
iboutchkine@hotmail.com
cruella69
June 23rd, 2000, 11:56 AM
What I really need to do is print something like this
Order# Qty Ord Date Ordered Date Shipped Date Ret.
1 2 1/1/00 2/1/00 3/1/00
2 2 2/1/00
3 3 3/1/00 4/1/00
The null dates display as 12/31/99 instead of blank. Any ideas?
cruella69
Iouri
June 23rd, 2000, 12:32 PM
What do you have in you database tabel Null or 12/31/99?
Iouri Boutchkine
iboutchkine@hotmail.com
cruella69
June 23rd, 2000, 01:17 PM
the dates are blank in the database
cruella69
Iouri
June 23rd, 2000, 01:37 PM
Try this:
dim s as string
If IsNull(Recordset!ShipDate) then
s=""
Else
s = CStr(rs!ShipDate)
End If
Printer.Print rs!Order# & rs!Qty & rs!OrdDate & rs!ShipDate & rs!RetDate
Don't forget to include Spaces or Tabs between columns (I skipped them to be short)
Iouri Boutchkine
iboutchkine@hotmail.com
cruella69
June 23rd, 2000, 03:24 PM
I finally came up with something that worked for what I needed. I declared a variable as a string, cleared the variable, if there was something in the date field I moved the contents to the string variable, otherwise I left it blank. When I print the string variable it either has something or it is blank.
Thanks for all your help. I really appreciate it!
cruella69
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.