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 
Update Pricing DMax
Thomas Colley 
     
2 years ago
I am trying to update pricing on a DB without the historical date prices changing. i am using the following code

Private Sub ProductID_AfterUpdate()
Me.PackagePrice = DMax("PackagePrice", _
                "PricingT", _
                "ProductID = " & Nz(Me!ProductID, 0) & " And EffectiveDate <= " & Format$(Me.Parent!EventDate, "\#mm\/dd\/yyyy\#"))
                Me.Refresh            
end Sub


I need it to be between 2 dates...EffectiveStartDate and EffectiveEndDate I don't know how to modify this code to make it work correctly. Any help would be greatly appreciated.
Alex Hedley  @Reply  
            
2 years ago
First thing I would do is create a hard coded query to check you can retrieve the data you expect.
Thomas Colley OP  @Reply  
     
2 years ago
Not sure what you man by a hard coded query, the code works if i take out the < but the Eventdate needs to be the same as the EffectiveDate. I want to put an EffectiveStartDate and EffectiveEndDate in my PriceT and when the EventDate falls between those 2 dates then it gives me the price that's set for those dates.
Alex Hedley  @Reply  
            
2 years ago
Hardcoded as in not taken from Form values.
You can replace 0 and #01/12/2024# with data you know exists.

SELECT PackagePrice
FROM PricingT
WHERE ProductID = 0
AND EffectiveDate <= #01/12/2024#


This is just Step 1 of a multi step process we'll work through together.
Richard Rost  @Reply  
          
2 years ago
Also, whenever I see date formatting like that, I always look for problems there. Remember, Format() will turn your date into a STRING.
Alex Hedley  @Reply  
            
2 years ago
Step 1 - simple hard coded query
Step 2 - Aggregate to get the  MAX
Step 3 - Between or <= / >=
Step 4 - replace one value with a variable
Step 5 - repeat with other variables
Step 6 - move to DMAX hardcoded
Step 7 - replace one value with a variable
Step 8 - repeat with other variables
Sami Shamma  @Reply  
             
2 years ago
Great advice Alex
Thomas Colley OP  @Reply  
     
2 years ago
Great, will try tomorrow and let you know
Thomas Colley OP  @Reply  
     
2 years ago
Finally got this to work using what i first posted. not sur how or why but sems to be working now. thank you all for your help

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/6/2026 3:29:49 PM. PLT: 1s