By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,479 Members | 2,239 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,479 IT Pros & Developers. It's quick & easy.

Dmax error: 2471

P: 55
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
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 634
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

P: 55
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.