Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Access Increment Custom Counter
Daniel 

15 years ago
Mr. Rost,
Thank you so much for your reply. I think I did as you suggested and made the following Procedure:
_______________________________________
Private Sub Form_BeforeInsert(Cancel As Integer)
    Me.JobID = DMax("[JobID]", "731DailyReportT", "[Date] = #" & Me.Date & "#") + 1
    If Me.JobID = Null Then Me.JobID = 1
End Sub
_____________________________

On opening the form I get "Run-Time Error '3075'

Syntax error in date in query expression '[Date] = ##'.
_____________________________
I understand that the date expression is not appropriate for the BeforeInsert even but, when it is in the OnLoad event and I manually put a 1 in the table, everything works fine afterward. Why is this query expression not accepted now? I am asking, because I do not understand how the expression works. After hundreds of failures, I found it in a forum post and applied it to my situation. That is why I an so lost. Thank you again for any and all assistance.

Daniel



Reply from Richard Rost:

First of all, "Date" is not a good name for a field or control because it's a reserved word in Access. I would change it to "MyDate" or something else. Now, if you want to check it against the CURRENT DATE, don't use Me.Date. That says you have a field on your current form called Date. You probably want to use Date() which is the date function that returns the current date. If Me.Date is NULL (which it probably is) then your DMAX function won't work.

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

Next Unseen

 
New Feature: Comment Live View
 
 

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 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/18/2026 6:39:13 AM. PLT: 1s