Run query from an Event Procedure MS Access
Posted on 2014-12-08
I have an Access form (MyForm) that has an event procedure under its On Activate event.
MyForm has a textbox on it (MyTextBox).
I have a table (MyTable) that contains a small list of specific dates.
In the On Activate event procedure, I want to query MyTable to see if the current date is one of the values in the table (field name is DateField). If it is, set the value of MyTextBox to the current date. If it isn't, do something else.
I don't want the query results displayed in a datasheet that I have to wind up closing or anything like that. I just want to query the table for the current date value. If it's in there, put that value in the textbox and be done with the query.
I do not want to use DLookup in any way, shape or form to accomplish this. I cannot stand DLookup. It always produces a noticeable annoying delay between the time it executes and the time it populates the control.