Results 1 to 2 of 2
  1. #1
    WickidWe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    123

    Matching Date Formats for Query in a form

    In the following Query, in the where clause the date selected in the form is to match a date in a table.

    sSQL = "UPDATE ((tblRosterRec INNER JOIN tblEmpDetails ON tblRosterRec.EmpId = tblEmpDetails.EmpId) " & _
    "INNER JOIN tblFunctions ON tblRosterRec.FctnID = tblFunctions.ReliefCode) " & _
    "INNER JOIN tblRelief_Allot ON (tblFunctions.ReliefCode = tblRelief_Allot.ReliefCode) " & _
    "AND (tblEmpDetails.EmpId = tblRelief_Allot.EmpId) " & _
    "SET tblEmpDetails.IsVisible = False, tblRelief_Allot.FctnSelected = True " & _
    "WHERE tblRosterRec.Date_=" & txtDate & " AND tblEmpDetails.EmpId=tblRosterRec.EmpId;"

    this is not doing anything do I need to format the date first?

    this is the query I made in the queryBuilder and it works a fine.



    UPDATE ((tblRosterRec INNER JOIN tblEmpDetails ON tblRosterRec.EmpId = tblEmpDetails.EmpId) INNER JOIN tblFunctions ON tblRosterRec.FctnID = tblFunctions.ReliefCode) INNER JOIN tblRelief_Allot ON (tblFunctions.ReliefCode = tblRelief_Allot.ReliefCode) AND (tblEmpDetails.EmpId = tblRelief_Allot.EmpId) SET tblEmpDetails.IsVisible = False, tblRelief_Allot.FctnSelected = True
    WHERE tblRosterRec.Date_=[Forms]![Form1]![txtDate] AND tblEmpDetails.EmpId=tblRosterRec.EmpId;

    I set up a Debug.Print for the SQL and below is the result

    UPDATE ((tblRosterRec INNER JOIN tblEmpDetails ON tblRosterRec.EmpId = tblEmpDetails.EmpId) INNER JOIN tblFunctions ON tblRosterRec.FctnID = tblFunctions.ReliefCode) INNER JOIN tblRelief_Allot ON (tblFunctions.ReliefCode = tblRelief_Allot.ReliefCode) AND (tblEmpDetails.EmpId = tblRelief_Allot.EmpId) SET tblEmpDetails.IsVisible = False, tblRelief_Allot.FctnSelected = True WHERE tblRosterRec.Date_=15/01/2014 AND tblEmpDetails.EmpId=tblRosterRec.EmpId;

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You need to surround the value with #

    "WHERE tblRosterRec.Date_=#" & txtDate & "# AND...
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Import from Excel file fails because of date formats
    By wardw in forum Import/Export Data
    Replies: 1
    Last Post: 01-01-2014, 02:20 AM
  2. Currency formats lost between Query and Word in Mail Merge
    By Monterey_Manzer in forum Import/Export Data
    Replies: 2
    Last Post: 07-17-2012, 02:43 PM
  3. Replies: 1
    Last Post: 10-24-2011, 08:01 AM
  4. Import Excel and date formats
    By thart21 in forum Import/Export Data
    Replies: 1
    Last Post: 04-19-2011, 03:49 PM
  5. Replies: 2
    Last Post: 08-17-2010, 01:10 PM

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