Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
 
Home > TechHelp > Directory > Access > DMax < Flashing Text | On Click >
Back to DMax    Comments List
Upload Images   @Reply   Bookmark    Link   Email  
DMax Error Issue
Stephen Gledhill 
     
6 months ago
I am trying to use DMax to look up a customer's last order date as detailed in this TechHelp video.
This is the function I have used in my form:
=DMax("SaleDate","tblOrder","CustomerID =" & [CustomerID])
When I save and reopen the form I get an #Error in my LastOdered field.
I wondered if this may be because both of the "CustomerID" fields are text rather than numeric?
I have spent a couple of hours trying to get this working using double quotes, but without success. Am I on the right track?
Kevin Robertson  @Reply  
           
6 months ago
=DMax("SaleDate","tblOrder","CustomerID=""" & [CustomerID] & """")

Double Double Quotes

Any reason why they are Text instead of Numbers?
Sami Shamma  @Reply  
             
6 months ago
"CustomerID" field is text defeat the purpose!
Stephen Gledhill OP  @Reply  
     
6 months ago
Many thanks - I'll try that!
The reason for the text instead of numbers I thought you may shout at me for that).
I am converting a database I use to manage my small business  to Access. I wrote it many years ago in Windows 98 days using Ffenics (used to be DataEase before the company split). It works well and I have developed it a lot over the years, but fear it may well stop working soon as each new version of Windows appears.
My customer form primary key field in Ffenics is the first 4 letters of the customer's surname and then a 4 figure number, so a length of 8 in total. I had to format this as a text. The same field appears as a foreign in the orders table.
I have over 7,000 customers and many thousands of orders, so keeping the fields as text seemed much easier than starting again with numeric autonumber fields!
Adam Schwanz  @Reply  
            
6 months ago
You can still use an auto-number primary key even if you have a good reason to use a text as primary key. Just use both. You don't ever have to worry about the auto-number or what it's value is, or even use it, but it may be able to save you some trouble in some areas.

You could also use some update queries and update all your tables to the correct customerID as an autonumber and throw out the text primary key (or change it to customertext and just use it as a normal field inside of your database for data instead of being a key).
Kevin Robertson  @Reply  
           
6 months ago
Stephen Gledhill OP  @Reply  
     
6 months ago
Thanks Adam / Kevin
I think (it's a long time ago) I went down this route initially for ease of checking if a customer was already in the database. By searching "SCHW*" I could instantly see all the "Schwanz's, then just click on the correct one to see the full details. If it wasn't already in I knew the next number in the four number part of the code was the next new number and there could be no duplicates.
I couldn't see how I could replicate that ease with a plain numeric field.
What benefits would an autonumber field give me?
Would it be better to replace it? It doesn't sound right to have two primary keys...
Thanks for the link Kevin.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in DMax.
 

 
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2025 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/22/2025 7:30:14 PM. PLT: 1s