Ran into a problem, just as I thought I had it working.
The problem I am running into is the strLastFiscalYe ar in the DMax field. The error I get is: Run Time error: 2471....The expression you entered as a query parameter produced this error: 'strLastFiscalY ear'
What I am trying to accomplish is that for instance that the current fiscal year is 2009 saved in table named YearReset, in the field CurrentFiscalYe ar. When a user tries to enter a record for the last fiscal year - 2008, the dmax is or should look in the database table TblDocket, find the largest RecordNumber of the record that the Fiscalyear equals 2008.
I can get it to work if I would just put 2008 where strLastFiscalYe ar is but that would not help for next years.
Any suggestions? Thanks again.
Code:
Dim strCurrentFiscalYear As String
strCurrentFiscalYear = DLookup("[CurrentFiscalYear]", "YearReset", "[ID] = 1")
Dim strLastFiscalYear As String
strLastFiscalYear = strCurrentFiscalYear - 1
strNewRecordNumber = DMax("[RecordNumber]", "TblDocket", "[FiscalYear] = strLastFiscalYear") + 1
What I am trying to accomplish is that for instance that the current fiscal year is 2009 saved in table named YearReset, in the field CurrentFiscalYe ar. When a user tries to enter a record for the last fiscal year - 2008, the dmax is or should look in the database table TblDocket, find the largest RecordNumber of the record that the Fiscalyear equals 2008.
I can get it to work if I would just put 2008 where strLastFiscalYe ar is but that would not help for next years.
Any suggestions? Thanks again.
Comment