Results 1 to 3 of 3
  1. #1
    robrich22's Avatar
    robrich22 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2013
    Location
    Louisville, KY
    Posts
    41

    Query with Date Variable

    I keep getting type mismatch error with a query



    SELECT * FROM [Log Watch] WHERE [Log Watch].EndDate=" & ReportDate &";

    I am building this query in sql view of the query builder and clicking run to view the results. Keeps telling me type mismatch.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,628
    Don't need the concatenation and quote marks.

    Build in Design view then switch to SQL view to see the statement.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Using VBA in a form module, you would use something like
    Code:
    strSQL = "SELECT * FROM [Log Watch] WHERE [Log Watch].EndDate= #" & Me.ReportDate &"#;"
    Notice the delimiters...

    In a saved query, you can't refer to the control "ReportDate" like that. It must be the fully qualified path.
    Code:
    SELECT * FROM [Log Watch] WHERE [Log Watch].EndDate= Forms!Form1.ReportDate;
    Change Form1 to your form name

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Date variable Store
    By drunkenneo in forum Programming
    Replies: 1
    Last Post: 07-01-2013, 05:57 AM
  2. using ADO, assigning a date variable
    By crowegreg in forum Programming
    Replies: 3
    Last Post: 08-23-2011, 12:00 AM
  3. Problem with filtering on DATE Variable
    By SIGMA248 in forum Programming
    Replies: 1
    Last Post: 04-01-2011, 10:33 AM
  4. Set date field on subform to date variable
    By laavista in forum Access
    Replies: 4
    Last Post: 06-30-2010, 06:32 PM
  5. set date field on form to date variable
    By laavista in forum Access
    Replies: 3
    Last Post: 06-28-2010, 03:03 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums