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 
look up data
Hamish 
    
14 years ago
          
Hi Richard,

I appreciate your feedback with the Dlookup function. I now have another question where I'm trying to Dlookup the price from a table


Table 1 should return $8.49 and not $7.99

Example Table 1

Item Group PSRP ComparePSRP Code
27971 A $8.49 $7.99 BR
27971 B $8.49 $7.99 BR



The problem I'm having is, that it's returning the first price of $7.99 and not $8.49 which I'm using as the Dlookup criteria.

I need your guidance on this once as I've been struggling to get my head around this for two days now.


VBA code example below:

rs.MoveFirst

       Do Until rs.EOF

               rs!ComparePSRP = Nz(DLookup("PSRP1", "Table2", "ItemNumber=" & rs!Item & " AND Code='" & rs!Code & "'"))
rs.MoveNext
      Loop

Week ItemNumber Group PSRP1 Code
43 27971 A $7.99 AS
26 27971 B $7.99 BR
40 27971 A $7.99 BR
26 27971 B $7.99 BR
28 27971 A $8.49 BR
8 27971 B $8.99 AS
28 27971 A $8.49 BR
31 27971 B $8.49 BR


Your expert advice is much appreciated

Regards

Hamish




Reply from Richard Rost:

DLOOKUP by itself is going to find the FIRST record in the table that meets the criteria. If you want the MOST RECENT data, you're going to need a second statement using DMAX to determine the highest ID that meets those criteria, then DLOOKUP the value using that ID.

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/16/2026 10:41:09 PM. PLT: 1s