Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2011
    Posts
    20

    Post How to format a date in list Box

    I have a Listbox, the RowSource is:
    Code:
     
    lstView.RowSource = "select ID,Chop_Date, GWIS_ID,Card_Number,Customer_Name,Complaint_Category,Status from tbl_PaperTeam"
    i need to format the date. so i modified the row source as



    Code:
     
    lstView.RowSource = "select ID,format([Chop_Date],"dd-mmm-yy"), GWIS_ID,Card_Number,Customer_Name,Complaint_Category,Status from tbl_PaperTeam"
    But after writing the code and going to next line i got the following error

    "Compile Error.Expected: end of statement"
    and the cursor is pointing on "dd-"
    How ever that query got executed when i checked in Query Window.

    Please assist me to get my expected format date

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Hi

    The syntax you are using will work as the SQL of a query, but if you are setting the "Row Source" property with code, then you need to replace the single quotes ("dd-mmm-yy") at each end of the date format with either double quotes (""dd-mmm-yy"") or with ("'"dd-mmm-yy"'").
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

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

Similar Threads

  1. Date field not in date format
    By Lorlai in forum Access
    Replies: 11
    Last Post: 06-27-2011, 05:14 PM
  2. Date Format
    By lonewolfwfk in forum Programming
    Replies: 4
    Last Post: 11-25-2010, 09:00 PM
  3. Format phone number in an unbound list box
    By kbremner in forum Forms
    Replies: 2
    Last Post: 11-08-2010, 05:11 PM
  4. date format
    By dollygg in forum Access
    Replies: 2
    Last Post: 01-19-2010, 10:14 AM
  5. Date Format
    By St3ph3n in forum Access
    Replies: 4
    Last Post: 03-09-2006, 11:23 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