dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Access dates with VB

  1. #1
    dgw Guest

    Access dates with VB


    Hi all,
    I'm trying to get a date based query returned to VB from access - but although
    the field in the database is defined as a Date I get a "Data type mismatch
    in criteria expression" error.

    I've tried playing around with everything I can think of so if anyone has
    any ideas why this happens i'd be grateful to hear them - even just suggestions.
    Thanks.

    Here's an excerpt from the code I'm using...

    dim quickdate as Date
    quickdate = Date - 8
    rscount.RecordSource = "SELECT * FROM Returned_Low where date_created > '"
    & quickdate & "'"



  2. #2
    Tim Martin Guest

    Re: Access dates with VB


    dgw-
    For ms-access, you need to surround your date with the # character, not the
    single quote.
    rscount.RecordSource = "SELECT * FROM Returned_Low where date_created > #"
    & quickdate & "#"
    tim

    "dgw" <dgw567@yahoo.co.uk> wrote:
    >
    >Hi all,
    >I'm trying to get a date based query returned to VB from access - but although
    >the field in the database is defined as a Date I get a "Data type mismatch
    >in criteria expression" error.
    >
    >I've tried playing around with everything I can think of so if anyone has
    >any ideas why this happens i'd be grateful to hear them - even just suggestions.
    >Thanks.
    >
    >Here's an excerpt from the code I'm using...
    >
    >dim quickdate as Date
    >quickdate = Date - 8
    >rscount.RecordSource = "SELECT * FROM Returned_Low where date_created >

    '"
    >& quickdate & "'"
    >
    >



  3. #3
    Dgw Guest

    Re: Access dates with VB


    Thanks Tim - it's always so easy when you know how!

    "Tim Martin" <tpmartin@NOSPAM_bigfoot.com> wrote:
    >
    >dgw-
    >For ms-access, you need to surround your date with the # character, not

    the
    >single quote.
    >rscount.RecordSource = "SELECT * FROM Returned_Low where date_created >

    #"
    >& quickdate & "#"
    >tim
    >
    >"dgw" <dgw567@yahoo.co.uk> wrote:
    >>
    >>Hi all,
    >>I'm trying to get a date based query returned to VB from access - but although
    >>the field in the database is defined as a Date I get a "Data type mismatch
    >>in criteria expression" error.
    >>
    >>I've tried playing around with everything I can think of so if anyone has
    >>any ideas why this happens i'd be grateful to hear them - even just suggestions.
    >>Thanks.
    >>
    >>Here's an excerpt from the code I'm using...
    >>
    >>dim quickdate as Date
    >>quickdate = Date - 8
    >>rscount.RecordSource = "SELECT * FROM Returned_Low where date_created >

    >'"
    >>& quickdate & "'"
    >>
    >>

    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center