Syntax error in date in query expression #My_date=01.07.2020.#

Anonymous
2020-07-01T17:21:08+00:00

Hello

I have vba code on the unbound combo box in access but when I load the form I get syntax error in date. My date format is dd.mm.yyyy.

Please see attached screenshot. Could someone help with this error. Thank you.

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes
Answer accepted by question author
  1. Anonymous
    2020-07-02T20:23:29+00:00

    Please notice, that a combobox can only hold text items, thus the first column will be FD_Date (or Date()) casted to text as to your regional settings of Windows.

    Also, I guess you wish to order by the date value, not the day. Then you would need a column like

    Format(Date(), "yyyymmdd")

    to order by.

    0 comments No comments

15 additional answers

Sort by: Most helpful
  1. Anonymous
    2020-07-02T15:18:25+00:00

    Yes it is a field date I mean column in table Food_Distribution. Unbound combo box where today's date set is called cboDate.

    0 comments No comments
  2. Anonymous
    2020-07-02T15:39:44+00:00

    As for the original code, we have no idea what the purpose of the combobox may be. It doesn't interact with the code you posted.

    As for the a date value, this has no format. A format is applied for display only.

    0 comments No comments
  3. Anonymous
    2020-07-02T19:44:36+00:00

    Combo box is set to receive present date when I open the form which has a subform where is loaded ID_Number, First_Name, Last_Name and Gender from tblFD. After all data has been loaded into subform which is bounded to table Food_Distribution where I have three check box for each meal Breakfast, Lunch and Dinner. When every person takes his meal I set checkbox to true and data are saved to table Food_Distribution.

    On combo box cboDate in the Row source is set:

    SELECT Food_Distribution.FD_Date, FORMAT(FD_DATE,"DDMMYYYY") FROM Food_Distribution ORDER BY 2  UNION SELECT DATE() AS FD_DATE, FORMAT(DATE(),"DDMMYYYY") FROM Date_Index ORDER BY 2;

    There is Data_Index table where is only one field with value 1 what you can see in the code.

    0 comments No comments