Results 1 to 5 of 5
  1. #1
    LonghronJ is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Posts
    150

    Syntax needed for Sql string involving formatting a date field

    I am getting Run-time error '424': "Object Required" with below Sql string. I can't figure out the issue. Please help me identify. Thanks.



    Code:
    strSQL = "SELECT qryPriorityList.[Customer Name], " & Format(qryPriorityList.[NeededBy], "mm/dd/yy") & " FROM qryPriorityList ORDER BY qryPriorityList.NeededBy"

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    you should build the sql in query design THEN convert to sql to avoid the errors.

    strSQL = "SELECT qryPriorityList.[Customer Name], " & Format(qryPriorityList.[NeededBy], "mm/dd/yy")

    I think: Format(qryPriorityList.[NeededBy], "mm/dd/yy") expects a field or
    Format(qryPriorityList.[NeededBy], "mm/dd/yy") as MyField

    since strings are not objects to get an error.

  3. #3
    LonghronJ is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Posts
    150
    I actually did and came up with what I have. I tried to add an alias, but it did not work.

  4. #4
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Try this:
    Code:
    strSQL = "SELECT qryPriorityList.[Customer Name], Format(qryPriorityList.[NeededBy], " & Chr(34) & "mm/dd/yy" & Chr(34) & ") FROM qryPriorityList ORDER BY qryPriorityList.NeededBy"

  5. #5
    LonghronJ is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Posts
    150
    JoeM, that worked great. Thanks.

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

Similar Threads

  1. Replies: 3
    Last Post: 12-02-2014, 07:58 PM
  2. How to Covert Date field to string
    By kassem in forum Programming
    Replies: 2
    Last Post: 06-05-2014, 09:06 AM
  3. Need to use an update query on date string field
    By clawschieff in forum Queries
    Replies: 2
    Last Post: 01-28-2014, 02:07 PM
  4. Recordsets and VBSQL + Date as String formatting
    By asdaf3814 in forum Programming
    Replies: 9
    Last Post: 11-21-2012, 06:40 PM
  5. Query involving a date calculation
    By bronzyroo in forum Queries
    Replies: 2
    Last Post: 02-14-2012, 11:41 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