I am trying to build a date coding system in Access. A set of number is automatically generated on daily basis started from 1 everyday. These data are stored in a table call T_Job with following fields.
Job_ID
Production_Date
Recipe_ID
Recipe_Ver
QTY
UOM
DailyNumber
In the active form, I have a text box named txtProductionDate that user can enter production date. The date value from this text box is then passed to a vba variable called ProdDate.
In the vba, I tried this code just to see if this approach works.
Expand|Select|Wrap|Line Numbers
- Dim ProdDate As Date
- ProdDate = Me.[txtProductionDate].Value
- MsgBox Nz(DMax("[DailyNumber]", "[T_Job]", Production_Date = ProdDate), 0), vbOKOnly
On the other hand, when I tried the code in the Immediate panel below the vba editor, the message box returns correct number.
Can anyone tell me what went wrong with the code?
Thanks,
Joe