473,659 Members | 2,980 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dmax error: 2471

55 New Member
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 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.
Jul 25 '08 #1
2 4776
MikeTheBike
639 Recognized Expert Contributor
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 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.
Hi

Try this

Dim strLastFiscalYe ar As String

strLastFiscalYe ar = strCurrentFisca lYear - 1

strNewRecordNum ber = DMax("[RecordNumber]", "TblDocket" , "[FiscalYear] = " & strLastFiscalYe ar) + 1

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

Also, I think 'strCurrentFisc alYear', 'strLastFiscalY ear' and 'strNewRecordNu mber' should be Integers not a strings ??


MTB
Jul 25 '08 #2
barmatt80
55 New Member
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
5861
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 like to insert the next "ET Number" when I append new records into the tblImportET. = ! + 1 i tried this sql code but i received an input pop-up box indicating i
4
2266
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 terms: I have a database which is in design for a new Development Request system. The main 2 tables are linked one to many, by in this instance say DWR_ID.
1
4993
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, FormatCount As Integer) Dim strcount As Double, strpts As Double
4
4049
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 XPP. Here's a snapshot of the table data: InvoiceID 79571 79572 ACCT ACCT
3
5819
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 FE for adding/editing transactions. Using TransactionID control as autonumber/primary key for tblTransactions. A while back, when I mentioned here that I was showing that control to my users as the transaction number, someone (can't remember who...
2
5650
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 table using dmax, which references another query to update the table. Although I have all of the correct keys from the physical table joined to the query in the dmax function, the code/ms access seems to ignore the joins. As a result, all payees...
1
4113
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 is the code for my query for this report: SELECT .*, .QualityAssuarnce, .CallDate FROM INNER JOIN ON . = .
1
4776
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 getting the error "MyDatabase" can't find the field '|' referred to in your expression. Please help, I am going crazy here :)!
21
4626
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 info, I think not important to this thread DATE_SHIP (date) Then I have a field STICKS_EXPIRE: DateAdd("yyyy",2,) with criteria Between And where and are parameters.
0
8428
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8335
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8747
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8528
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8627
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.