467,212 Members | 1,176 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,212 developers. It's quick & easy.

Dmax error: 2471

Ran into a problem, just as I thought I had it working.

Expand|Select|Wrap|Line Numbers
  1. Dim strCurrentFiscalYear As String
  2.     strCurrentFiscalYear = DLookup("[CurrentFiscalYear]", "YearReset", "[ID] = 1")
  3. Dim strLastFiscalYear As String
  4.     strLastFiscalYear = strCurrentFiscalYear - 1
  5. strNewRecordNumber = DMax("[RecordNumber]", "TblDocket", "[FiscalYear] = strLastFiscalYear") + 1
The problem I am running into is the strLastFiscalYear in the DMax field. The error I get is: Run Time error: 2471....The expression you entered as a query parameter produced this error: 'strLastFiscalYear'

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 CurrentFiscalYear. 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 strLastFiscalYear is but that would not help for next years.

Any suggestions? Thanks again.
Jul 25 '08 #1
  • viewed: 4234
Share:
2 Replies
Expert 512MB
Ran into a problem, just as I thought I had it working.

Expand|Select|Wrap|Line Numbers
  1. Dim strCurrentFiscalYear As String
  2.     strCurrentFiscalYear = DLookup("[CurrentFiscalYear]", "YearReset", "[ID] = 1")
  3. Dim strLastFiscalYear As String
  4.     strLastFiscalYear = strCurrentFiscalYear - 1
  5. strNewRecordNumber = DMax("[RecordNumber]", "TblDocket", "[FiscalYear] = strLastFiscalYear") + 1
The problem I am running into is the strLastFiscalYear in the DMax field. The error I get is: Run Time error: 2471....The expression you entered as a query parameter produced this error: 'strLastFiscalYear'

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 CurrentFiscalYear. 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 strLastFiscalYear is but that would not help for next years.

Any suggestions? Thanks again.
Hi

Try this

Dim strLastFiscalYear As String

strLastFiscalYear = strCurrentFiscalYear - 1

strNewRecordNumber = DMax("[RecordNumber]", "TblDocket", "[FiscalYear] = " & strLastFiscalYear) + 1

strLastFiscalYear is a variable, you have made part of a literal string (it need concatenating into the string as above).

Also, I think 'strCurrentFiscalYear', 'strLastFiscalYear' and 'strNewRecordNumber' should be Integers not a strings ??


MTB
Jul 25 '08 #2
thanks mike! worked great. yes they should be integers. I am working on changing them now.

thanks again
Jul 25 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by nrtyme@gmail.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.