PDA

Click to See Complete Forum and Search --> : VB6 MaskedBox and Access DB Date data type


Mar 26th, 2000, 07:00 PM
Hi, My name is Joseph and am a beginner in VB. I have created various forms that have a MaskEdBox with the mask of ##/##/#### to portray the Date. In my Access Database I have the field data type defined as Date (ShortDate). When I update a new record in VB6 I receive the Error Occurred message. When I go to the Access db and chage the data type of the date field to text and update a new record in VB6 no errors occur. When I create reports in Access (data Type = text) and use criteria in the date field, for example Between "01/01/1999" And "12/31/1999" or "01011999" And "01311999" the report shows other dates that are not in the range selected. However if I change the field data type to Date and replace the quotes " for # the report gives me valid data. I would like to know how I can use the mask in vb6, maintain the field as a date field rather than a text so that my reports produce valid data.

Thanks Joe

Forest Dragon
Mar 30th, 2000, 06:41 PM
I suggest not using the MaskEdBox at all. Instead of it, use a regular TextBox control and before updating the record, check if its Text property contains a valid date by using the IsDate function.

Good Luck!!!

Apr 1st, 2000, 03:57 AM
I agree with you, however, I like what the maskedbox does for the users, it gives them that Format __/__/____
which I believes assures at least a correct mm/dd/yyyy reply. Is there another way this can be done using the text box ????

MetallicaD
Apr 10th, 2001, 05:44 PM
for the __/__/____ mask, what if the user types
83/78/2002? you need logic to check if month <=12, day <=31 (how about feb? not 31 days, sometimes 28, sometimes 29).

imho, using IsDate() is the way to go, but this still requires the user to type in the slashes...sob