Results 1 to 4 of 4

Thread: VB6 MaskedBox and Access DB Date data type

  1. #1
    Guest
    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

  2. #2
    Addicted Member
    Join Date
    Oct 1999
    Posts
    253
    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!!!

  3. #3
    Guest
    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 ????

  4. #4
    Hyperactive Member MetallicaD's Avatar
    Join Date
    Feb 2001
    Location
    Tallahassee, FL
    Posts
    488

    does that assure you of a valid date?

    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
    [vbcode]
    '*****************************
    MsgBox "MCD :: [email protected]", vbInformation + vbOKOnly, "User"
    '*****************************
    [/vbcode]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width