Dealing with "unknown" dates

J

Jim Shaw

BlankI'm having trouble finding a consistent way, or even a set of working ways, to dealing with variables of type date when I want to indicate that there is no date. I keep getting "Invalid use of Null", "invalid syntax" or "Type mismatch" messages. I've tried in both date and string types, nothing seems to work consistently across my situations. I've used, Null, #00/00/00#, 0, "" ... nothing seems to work reliably.

In Access/XT I have:
a.. a table with a date column upon which I define DAO.record
b.. a form with VBA code that manipulates dates
c.. a class object that has a date type property.
In my VBA code, if I assign the date in the table to the class object date property and the date field in the table has no date, I get "Invalid use of Null"

In my VBA code, I'd like to explicitly set the date object date property to a state indicating that there is no date specified, and then be able to test for that in my class object code.

When in the debugger I look at an empty date record, the date is displayed as "Null", but I'm not allowed to set it to null in the tables datasheet view, nor can I set it to zero!!??

If I have a valid date, everything grows well. But if I have no date, everything falls apart.

What is a good day to cope with a unknown or unspecified date situation?

Thanks
-Jim
 
S

SA

BlankJim:

In VBA, before there as a Date data type, Dates were always typed as
Variants, which is what you should use. Variants of course accept nulls,
you can always test a variant for IsNull( which you can also do with your
field before assigning it even to a Date data type, and if its null assign
some value like 01/01/1900), You can test a variant for a valid date using
the IsDate () function.
--
Steve Arbaugh
ACG Soft
http://ourworld.compuserve.com/homepages/attac-cg

I'm having trouble finding a consistent way, or even a set of working ways,
to dealing with variables of type date when I want to indicate that there is
no date. I keep getting "Invalid use of Null", "invalid syntax" or "Type
mismatch" messages. I've tried in both date and string types, nothing seems
to work consistently across my situations. I've used, Null, #00/00/00#, 0,
"" ... nothing seems to work reliably.

In Access/XT I have:
a table with a date column upon which I define DAO.record
a form with VBA code that manipulates dates
a class object that has a date type property.
In my VBA code, if I assign the date in the table to the class object date
property and the date field in the table has no date, I get "Invalid use of
Null"

In my VBA code, I'd like to explicitly set the date object date property to
a state indicating that there is no date specified, and then be able to test
for that in my class object code.

When in the debugger I look at an empty date record, the date is displayed
as "Null", but I'm not allowed to set it to null in the tables datasheet
view, nor can I set it to zero!!??

If I have a valid date, everything grows well. But if I have no date,
everything falls apart.

What is a good day to cope with a unknown or unspecified date situation?

Thanks
-Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top