473,401 Members | 2,127 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,401 software developers and data experts.

Dmax criteria to limit only NUMBERS pulled from field that also may contain ALPHA

2
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
CREDIT
79572
79573

Here's the code I'm using:

MaxInvoiceID = DMax("[InvoiceID]", "Invoice")

MaxInvoiceID ends up being "CREDIT"

I would like Dmax to ignore alpha and only process numeric data.

I.E. MaxinvoiceID = 79573

Then I can add 1 to it and generate my new invoice number.

The SQL to do this seems to be:

SELECT Invoice.InvoiceID
FROM Invoice
WHERE (((Invoice.InvoiceID) Like "*#"));

The above SQL generates an alpha-free output:

InvoiceID
79568
79569
79570
79571
79572
79573

Sooooo, simply drop in the SQL "Where" criteria at the end of Dmax statement, right? Well, I can't seem to get it to work.

Here's what I'm running:
Expand|Select|Wrap|Line Numbers
  1. MaxInvoiceID = DMax("[InvoiceID]", "Invoice", "InvoiceID" Like "*#") 
<------wrong use of quotes or brackets?

When I run the code it complains of, "invaid use of Null."

Please help!
Apr 8 '07 #1
4 4035
Rabbit
12,516 Expert Mod 8TB
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
CREDIT
79572
79573

Here's the code I'm using:

MaxInvoiceID = DMax("[InvoiceID]", "Invoice")

MaxInvoiceID ends up being "CREDIT"

I would like Dmax to ignore alpha and only process numeric data.

I.E. MaxinvoiceID = 79573

Then I can add 1 to it and generate my new invoice number.

The SQL to do this seems to be:

SELECT Invoice.InvoiceID
FROM Invoice
WHERE (((Invoice.InvoiceID) Like "*#"));

The above SQL generates an alpha-free output:

InvoiceID
79568
79569
79570
79571
79572
79573

Sooooo, simply drop in the SQL "Where" criteria at the end of Dmax statement, right? Well, I can't seem to get it to work.

Here's what I'm running:
Expand|Select|Wrap|Line Numbers
  1. MaxInvoiceID = DMax("[InvoiceID]", "Invoice", "InvoiceID" Like "*#") 
<------wrong use of quotes or brackets?

When I run the code it complains of, "invaid use of Null."

Please help!
Use
Expand|Select|Wrap|Line Numbers
  1. DMax("Val([InvoiceID])", "Invoice")
Apr 8 '07 #2
gps
2
that's the ticket, thanks!
Apr 8 '07 #3
Rabbit
12,516 Expert Mod 8TB
that's the ticket, thanks!
Not a problem.
Apr 8 '07 #4
nico5038
3,080 Expert 2GB
Minor addition, when your alpha field contains a mixed value like:
1234ALSO
Then 1234 will be used by the VAL() function.
In such a case you can add an IIF() function to exclude these values, when you don't want them.

Success with your application !

Nic;o)
Apr 8 '07 #5

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

Similar topics

6
by: AAVF | last post by:
Hi We have a problem with a query. An Access database links via ODBC to a UNIX server. To speed things, we use the ODBC to load the relevant tables to the local PC that runs Access so that...
0
by: Jason | last post by:
I would like to be able to place a command button on a primary (parent) form that opens up a subform. I want to use this subform to search for or limit the recordset of data in the primary form. ...
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...
2
by: tricard | last post by:
Good day all, I have a large outer joined query that I want to have some criteria. The select query is gathering all part numbers from tblPartNumbers, left joining to tblPartNumberVendor (since...
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...
3
by: seagullino | last post by:
Hello, I've developed my first Form, a simple affair that enables the user to search text in the memo fields in our database. When the "search" button is pressed, it runs a macro which runs the...
6
by: vljones | last post by:
I have the following in Db:- tbl_Est - Num_ClaimNo - Date_Date - Num_Estimate I need this query to link to data in another table - tbl_Bord05, in which there is also a...
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: 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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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:
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.