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 
Query Results complicated
Carl Byerley 
        
3 years ago
I have a shipping business, On my order form I have multiple shippers on one order.
When I dispatch this order I have to select a Driver.
Problem 1. Some Driver have been banned or forbidden to go to a certain shipper but they are ok for others.
I have a table for DriversNotAllowed and my Shipper Table.

So far I have it so if I select a driver my info will tell me he is Banned. However I have over 50,000 drivers in my database. If a driver is banned in multiple shippers I do not need to see the entire list. I only want to see the message if the driver I select is banned on one of the shippers in the current order.

In my head it is simple (look at the Banned list and tell me if this driver is banned for any of these shippers.) Which is the end result I am looking for.

I have included img of the form, The shipper form consists of 3 subforms, Pickup, Stops, Delivery
The Driver form is a subform.

Can anyone give me ideas on how to make this work.
Carl Byerley OP  @Reply  
        
3 years ago

Carl Byerley OP  @Reply  
        
3 years ago

John Davy  @Reply  
         
3 years ago
Hi Carl
Take a look at Richards Video Many to Many, for I think you need to create an intermediate table with the DriverId and the ShipperID. You will need to flag only the banned drivers from a given shipper. Not too difficult once you see the many to many in Richards Video
HTH  John
John Davy  @Reply  
         
3 years ago
Hi Carl
I build a prototype together for you to get you started. If you send your email address to me at [email protected], I will send it to you. It is not a finished product but it will show you the potential of a many to many relationship. If you need further help, let me know.  John
Kevin Yip  @Reply  
     
3 years ago
Hi Carl, I suggest adding a textbox next to the combo box that would show "Banned" depending on the driver selected in the combo box (see picture below).  This textbox would contain a calculated field that would check the selected driver against the selected shippers to determine if the driver is banned.

On your order form, how many shippers can you enter?  Let's say an order can have up to 3 shippers, named ShipperID1, ShipperID2, and ShipperID3.  And the driver's combo box is named DriverID.

If your banned driver list is in a table named BannedDriversT, and it looks like this:

BannedDriverID    BannedByShipperID
121               12
121               30
379               12
402               78
576               5
576               9
576               12
Etc.
(Driver# 121 is banned by shipper# 12 and 30; shipper 12 bans driver 121, 379, and 576, etc.)


Then the textbox that is supposed to show "Banned" should have this formula:

=IIf(IsNull(DLookup("BannedDriverID", "BannedDriversT", "BannedDriverID=" & Nz(DriverID, 0) & " And BannedByShipperID IN (" & Nz(ShipperID1, 0) & ", " & Nz(ShipperID2, 0) & ", " & Nz(ShipperID3, 0))), "", "Banned")

In this expression, the DLookup() function checks if the selected driver AND *any one* of the selected shippers are in the same record in the banned drivers table.  If they do, that means the driver is banned by one of the shippers.  If they don't, DLookup() will return null, and the word "Banned" won't show.  

All the Nz() functions above are used because I assume all the IDs are numeric in your setup and they could be null on the order form if no entry is made.  If they are null, Nz() turns them into zeroes, which can be used to indicate nonexistent driver or shippers -- because autonumber fields (often used by IDs) always start from 1 and could never be zero.
Kevin Yip  @Reply  
     
3 years ago

Kevin Yip  @Reply  
     
3 years ago
Note that my formula does not involve your driver table, which you say has 50,000 records.  This is to improve performance.  My formula only uses your banned driver list, which I assume is a much smaller table in your database.
Carl Byerley OP  @Reply  
        
3 years ago
Thank you very much Kevin, this works great
John Davy  @Reply  
         
3 years ago
Hi, I think you should follow Kevin's advice.  I am happy that you found a solution that works.  John

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: 6/16/2026 7:31:33 PM. PLT: 0s