473,386 Members | 1,644 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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
2 4758
MikeTheBike
639 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

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

Similar topics

4
by: JMCN | last post by:
is it possible to insert a value into a field when you append the new records to the table instead of appending the one new record at a time in order to insert a new value? for example, i would...
4
by: lukeargent | last post by:
Hi All, I have come across some rather weird error that I can only assume is something to do with my ADP file connecting to SQL Server 2000. I'm using Access XP as my front end. In simple...
1
by: linoleum79 | last post by:
I'm getting this error: run-time error 2471 'The object doesn't contain the Automation object 'qry_prodreport_ALL.SSN." Here is the code: Private Sub GroupFooter0_Format(Cancel As Integer,...
4
by: gps | last post by:
I'm trying to use Dmax to dip into a my invoice header table and pull the maxium invoice number out of it. I'm running Access 2007 on Vista Business, but had the same prob with Access 2003 on...
3
by: Ron | last post by:
Hi All, Okay, here's the deal: Access2000/WinXP. Have a database that's split, FE/BE with multiple users having FE and one of those users also has BE (still split though...). Have a form on...
2
by: joeyrhyulz | last post by:
Hi, I'm trying to make a very simple update statement (in Oracle) in jet sql that seems much more difficult than it should be. The root of my problem is that I'm trying to update a field on a...
1
by: zufie | last post by:
I am trying to run a report, but I get the Microsoft Visual Basic Run- Time Error '2471': Unknown I googled the error and found that the Run-Time Error 2471 points to an "Item in query". Here...
1
by: nrtyme | last post by:
Hello, I need to add several new records to Table2 from Table1. Table2 contains a field called that needs to be the previous maximum value of incremented by 1. Below is my code but i keep...
21
by: DanicaDear | last post by:
I have a report named "rptHOTSTICKS_EXPIRING" based on a query named "HOSTICKS_SHIPPING_REPORT Query". The query contains these fields: ORDER_NUM (text) CUST_NUM (text) Name, address, contact...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.