Using a query to populate a text box control

wkosr46

New member
Local time
Today, 12:00
Joined
May 27, 2019
Messages
5
I am using two tables linked to a form to keep track of repeated accounting operations which must be done each month. After finishing a particular month (usually about 5 or 6 days into the following month, I add the required control records for the active month designated as "yyyy-mm".

I want to find out the last month in the file, populate the text box and then use that to run a query which will bring up all the records for that month.

A sampling of the records looks like this:

JEDesc YR-Mon JENum Ready Posted
BCBSxxxx 2019-04 ##### FALSE FALSE
MedBrgA 2019-04 ##### FALSE FALSE
BCBSxxxx 2019-05 ##### FALSE FALSE
MedBrgA 2019-05 ##### FALSE FALSE
SupLifexx 2019-05 ##### FALSE FALSE
BrzMinRx 2019-05 ##### FALSE FALSE
Donations 2019-05 ##### FALSE FALSE
MPRxxxxx 2019-05 ##### FALSE FALSE
FldAdBrz 2019-05 ##### FALSE FALSE
FldAdCol 2019-05 ##### FALSE FALSE
FldAdPerx 2019-05 ##### FALSE FALSE
PerMinxx 2019-05 ##### FALSE FALSE
PerSASpe 2019-05 ##### FALSE FALSE

I want to find the most recent YYYY-MM and use that value to only bring up the records for that current month. At the close of the month, a new month is set up. The current month should come up automatically when the form opens rather than being selected by the user.

I've tried setting the default value a number of different ways:

=DMax([tblJEList2],[YR-Mon]
and
=Select Max(tblJEList2!YR-Mon) As CurYRMon From tblJEList2

but I keep getting errors.

I've also tried to do an OnLoad Event and use DoCmd.RunSql after defining a Select statement in SQL.

Nothing I've tried works.

Thanks for any help.

:banghead:
 
Thank you. I did not realize that I needed to use quotes when I was entering a field name in brackets. That solved the problem, using DMAX() to set the default value of the text box. Greatly appreciated.
 

Users who are viewing this thread

Back
Top Bottom