Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Null

Status
Not open for further replies.

EscapeUK

Programmer
Jul 7, 2000
438
GB
i have a date var, if it is a 0 length I want to pass a null into it how do i do this.

 
As far as I know, the only variable type that can be set to NULL is Variant. All the others Date, String, Integer, have default values that are set upon declaration and can only be overwritten by other valid values, but not NULL.

A work around that I used when interacting between a VB front end and an Access database was to declare my variable intended for the date as a variant. Then I checked the user input. If it was empty then, I would assign NULL to my variable. If a value was entered, I would use the IsDate() function to establish that the entry was a correct date format.

At this point, I passed the entry to the database where it would be sorted properly.

Whether or not you can use this depends on what your program is and how you intend using the dates entered.

Do post if you find a better way. I was never that enamoured with my own way of doing this.


Brendan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top