Share via

Access 2016 Date function not working

Anonymous
2016-09-23T04:49:46+00:00

Hi,

I have an access application that has been working perfectly until I installed Access 2016.  Now, the following VBA code snippet returns an error:

MySQL = "SELECT TOP 1 Event.ID FROM Event WHERE (((Event.EventDate)>=Date()) And ((Event.CarnivalID)= " + CStr(intID) + ")) ORDER BY Event.ID;"

Set rs = CurrentDb.OpenRecordset(MySQL)

The error is "Undefined function Date in expression"

When I create a new query using the value of MySQL

SELECT TOP 1 Event.ID FROM Event WHERE (((Event.EventDate)>=Date()) And ((Event.CarnivalID)= 9)) ORDER BY Event.ID;

and run this query, I of course get the same error

When I enter ?Date in the immediate mode I am returned todays date, so the Date function is working.

I have checked all references and none are "missing"

This exact code works find under all version of Access prior to 2016 - can you help please

***Post moved by the moderator to the appropriate forum category.***

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

1 answer

Sort by: Most helpful
  1. Anonymous
    2016-09-23T10:22:03+00:00

    Do you have a field or control named Date?  This is normally the cause of such an error.

    You could use now() instead and format it as required for your query.

    Was this answer helpful?

    0 comments No comments