|
-
June 23rd, 2000, 09:18 AM
#1
Null Dates
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
-
June 23rd, 2000, 09:33 AM
#2
Re: Null Dates
In your SQL select statement which eliminate records with Null dates
Select * from YourTable where IsDate(DateShipped) = True
Iouri Boutchkine
[email protected]
-
June 23rd, 2000, 11:07 AM
#3
Re: Null Dates
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
-
June 23rd, 2000, 11:32 AM
#4
Re: Null Dates
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
[email protected]
-
June 23rd, 2000, 11:56 AM
#5
Re: Null Dates
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
-
June 23rd, 2000, 12:32 PM
#6
Re: Null Dates
What do you have in you database tabel Null or 12/31/99?
Iouri Boutchkine
[email protected]
-
June 23rd, 2000, 01:17 PM
#7
Re: Null Dates
the dates are blank in the database
cruella69
-
June 23rd, 2000, 01:37 PM
#8
Re: Null Dates
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
[email protected]
-
June 23rd, 2000, 03:24 PM
#9
Re: Null Dates
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|