I have a database which tracks boats and their maintenance, with the idea that it will produce reports/mailmerge when specific maintenance items are due (based on 6 or 12 months since they were last done). All working well as far as data entry and calculation of due dates.
However when I try to produce a query showing items due in , say, the next month, I get into trouble.
I am using a query showing the 6 separate maintenance items (eg antifouling, engine repair) with criteria for the due dates usings OR so that I can pick up any of the six items due in that month. However there is a logic flaw to the way I am doing it as the results show the due dates for all 6 items if any one of the items meets the query criteria. Thus is an antifoul is due in May, the query will also show all the other 5 items due dates even though they are in not in the month. I understand the program is doing exactly what I effectively asked for but wondered Is there a way I can pick up only the items that are due that month . Hope this makes sense
Steve
![]() |
Patch reliability is unclear, but widespread attacks make patching prudent. Go ahead and patch, but watch out for potential problems. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Join Queries (2000)
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Join Queries (2000)
- This topic has 9 replies, 2 voices, and was last updated 21 years, 1 month ago.
AuthorTopicWSstevecox4444
AskWoody LoungerMarch 17, 2004 at 8:43 pm #402433Viewing 1 reply threadAuthorReplies-
WSHansV
AskWoody Lounger -
WSstevecox4444
AskWoody LoungerMarch 18, 2004 at 2:59 am #800639Tables are:Customers,Boats,EngineManufacturer;BoatManufacturer
Boats is the main table and has fields for CustomerName, BoatName, EngineManufacturer, BoatManufacturer and then a series of fields for maintenance recording eg Date6mthEngineServiceDone,Date12mthEngineServiceDone,Date6mthAntifoulingDone,Date12mthAntifoulingdone, Antifoulingprodctcolour, Antifoulingqtyused, Antifoulingproductused etc.
In addition for each of the “datedone”items, there is a date due. This date due is calculated in the form used for data entry and is stored in the equivalent datedue field for each category in the table. eg once you enter the date the 6 monthly engine service is done, it adds 6 months and stores this in the Date6mthEngineServiceDUE field. All this is working wonderfully (based on a lot of help from this forum). My issue is then getting a query to show what maintenance tasks are due in the next ,say,month.
I have a query which sets as the criteria Date6mthEngineServiceDue in next month OR Date12mthEngineServiceDUE or Date6MthAntifoulingdue etc .
This query works exactly as specified eg it finds all the Customers who have a 6 mth antifoul due next month. However because I am showing all the maintanence items in the query, it also shows the date when the Customers 12mthEngineserviceisdue and the 6mthantifoul and the 12mthAntifoul etc etc. – quite logical based on the OR ie if any crieria for any of the maintenance items is met, it shows the date of all the maintenance items
I want it to show only those items due in the next month for that customer
Hope this helps
Steve -
WSstevecox4444
AskWoody LoungerMarch 18, 2004 at 3:02 am #800641Sorry – SQL as requested – in this example I am looking for any maintence duw in next 3 months
SELECT Boats.OwnerName, Boats.[Boat Name], Boats.BoatManufacturer, Boats.MotorManufacturer, Boats.Engines6mthServiceDue, Boats.Engine12mthServiceDue, Boats.AntiFouling6mthsDue, Boats.AntiFouling12mthsDue, Boats.Leg6mthServiceDue, Boats.Leg12mthServiceDue, *
FROM Boats
WHERE (((Boats.Engines6mthServiceDue) Between Date() And DateAdd(“m”,3,Date()))) OR (((Boats.Engine12mthServiceDue) Between Date() And DateAdd(“m”,3,Date()))) OR (((Boats.AntiFouling6mthsDue) Between Date() And DateAdd(“m”,3,Date()))) OR (((Boats.AntiFouling12mthsDue) Between Date() And DateAdd(“m”,3,Date()))) OR (((Boats.Leg6mthServiceDue) Between Date() And DateAdd(“m”,3,Date()))) OR (((Boats.Leg12mthServiceDue) Between Date() And DateAdd(“m”,3,Date()))); -
WSHansV
AskWoody LoungerMarch 18, 2004 at 7:41 am #800655Your problem is mainly the result of the design of the Boats table. I would have used several tables:
tblBoats to store “static” info about boats, with a primary key BoatID (AutoNumber), plus fields such as BoatName, but no service information.
tblServiceTypes to store “static” info about the types of service, with a primary key ServiceTypeID (AutoNumber), and for example a text field ServiceType.
tblBoatServicing as a link table, containing BoatID and ServiceTypeID (number, long integer) as a composite primary key, plus fields DateDue, DateDone, plus further info specific to this service instance. tblBoatServicing would be linked to the other two tables on the field of the same name (with referential integrity enforced, and cascading deletes)But you probably don’t want to change the structure now. Create a query based on Boats. Add the “general” fields you want to display: probably OwnerName, [Boat Name], BoatManufacturer and MotorManufacturer. For each of the “due” fields, add a calculated field like this, taking Engines6mthServiceDue as example:
Engines6mthServiceDue: IIf([Boats].[Engines6mthServiceDue] Between Date() And DateAdd(“m”,3,Date()),[Boats].[Engines6mthServiceDue],Null)
It is essential to add the table name in the expression, otherwise you would create a circular reference to Engines6mthServiceDue. If you switch to datasheet view now, you will see that most of the due date fields are blank. Only those between today and three months from today are displayed. Back in design view, add Is Not Null as criteria for each of the “due” fields, on a different line for each, so that you create “Or” conditions. Your query will now select only those records who have a “due” date in the next three months, and only displays dates falling within that period.
-
WSstevecox4444
AskWoody Lounger -
WSstevecox4444
AskWoody Lounger
-
-
-
WSHansV
AskWoody LoungerMarch 18, 2004 at 7:41 am #800656Your problem is mainly the result of the design of the Boats table. I would have used several tables:
tblBoats to store “static” info about boats, with a primary key BoatID (AutoNumber), plus fields such as BoatName, but no service information.
tblServiceTypes to store “static” info about the types of service, with a primary key ServiceTypeID (AutoNumber), and for example a text field ServiceType.
tblBoatServicing as a link table, containing BoatID and ServiceTypeID (number, long integer) as a composite primary key, plus fields DateDue, DateDone, plus further info specific to this service instance. tblBoatServicing would be linked to the other two tables on the field of the same name (with referential integrity enforced, and cascading deletes)But you probably don’t want to change the structure now. Create a query based on Boats. Add the “general” fields you want to display: probably OwnerName, [Boat Name], BoatManufacturer and MotorManufacturer. For each of the “due” fields, add a calculated field like this, taking Engines6mthServiceDue as example:
Engines6mthServiceDue: IIf([Boats].[Engines6mthServiceDue] Between Date() And DateAdd(“m”,3,Date()),[Boats].[Engines6mthServiceDue],Null)
It is essential to add the table name in the expression, otherwise you would create a circular reference to Engines6mthServiceDue. If you switch to datasheet view now, you will see that most of the due date fields are blank. Only those between today and three months from today are displayed. Back in design view, add Is Not Null as criteria for each of the “due” fields, on a different line for each, so that you create “Or” conditions. Your query will now select only those records who have a “due” date in the next three months, and only displays dates falling within that period.
-
WSstevecox4444
AskWoody LoungerMarch 18, 2004 at 2:59 am #800640Tables are:Customers,Boats,EngineManufacturer;BoatManufacturer
Boats is the main table and has fields for CustomerName, BoatName, EngineManufacturer, BoatManufacturer and then a series of fields for maintenance recording eg Date6mthEngineServiceDone,Date12mthEngineServiceDone,Date6mthAntifoulingDone,Date12mthAntifoulingdone, Antifoulingprodctcolour, Antifoulingqtyused, Antifoulingproductused etc.
In addition for each of the “datedone”items, there is a date due. This date due is calculated in the form used for data entry and is stored in the equivalent datedue field for each category in the table. eg once you enter the date the 6 monthly engine service is done, it adds 6 months and stores this in the Date6mthEngineServiceDUE field. All this is working wonderfully (based on a lot of help from this forum). My issue is then getting a query to show what maintenance tasks are due in the next ,say,month.
I have a query which sets as the criteria Date6mthEngineServiceDue in next month OR Date12mthEngineServiceDUE or Date6MthAntifoulingdue etc .
This query works exactly as specified eg it finds all the Customers who have a 6 mth antifoul due next month. However because I am showing all the maintanence items in the query, it also shows the date when the Customers 12mthEngineserviceisdue and the 6mthantifoul and the 12mthAntifoul etc etc. – quite logical based on the OR ie if any crieria for any of the maintenance items is met, it shows the date of all the maintenance items
I want it to show only those items due in the next month for that customer
Hope this helps
SteveWSHansV
AskWoody LoungerViewing 1 reply thread -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Sycophancy in GPT-4o: What happened
by
Alex5723
3 hours, 44 minutes ago -
How can I install Skype on Windows 7?
by
Help
2 hours, 27 minutes ago -
Logitech MK850 Keyboard issues
by
Rush2112
1 hour, 18 minutes ago -
We live in a simulation
by
Alex5723
17 hours, 52 minutes ago -
Netplwiz not working
by
RetiredGeek
4 hours, 27 minutes ago -
Windows 11 24H2 is broadly available
by
Alex5723
1 day, 6 hours ago -
Microsoft is killing Authenticator
by
Alex5723
13 hours, 49 minutes ago -
Downloads folder location
by
CWBillow
1 day, 12 hours ago -
Remove a User from Login screen
by
CWBillow
8 hours, 22 minutes ago -
TikTok fined €530 million for sending European user data to China
by
Nibbled To Death By Ducks
1 day, 3 hours ago -
Microsoft Speech Recognition Service Error Code 1002
by
stanhutchings
1 day, 3 hours ago -
Is it a bug or is it expected?
by
Susan Bradley
1 day, 8 hours ago -
Image for Windows TBwinRE image not enough space on target location
by
bobolink
1 day, 3 hours ago -
Start menu jump lists for some apps might not work as expected on Windows 10
by
Susan Bradley
2 hours, 30 minutes ago -
Malicious Go Modules disk-wiping malware
by
Alex5723
1 day, 16 hours ago -
Multiple Partitions?
by
CWBillow
1 day, 17 hours ago -
World Passkey Day 2025
by
Alex5723
2 days, 10 hours ago -
Add serial device in Windows 11
by
Theodore Dawson
3 days, 1 hour ago -
Windows 11 users reportedly losing data due forced BitLocker encryption
by
Alex5723
1 day, 2 hours ago -
Cached credentials is not a new bug
by
Susan Bradley
3 days, 6 hours ago -
Win11 24H4 Slow!
by
Bob Bible
3 days, 6 hours ago -
Microsoft hiking XBox prices starting today due to Trump’s tariffs
by
Alex5723
3 days, 3 hours ago -
Asus adds “movement sensor” to their Graphics cards
by
n0ads
3 days, 8 hours ago -
‘Minority Report’ coming to NYC
by
Alex5723
3 days, 5 hours ago -
Apple notifies new victims of spyware attacks across the world
by
Alex5723
3 days, 17 hours ago -
Tracking content block list GONE in Firefox 138
by
Bob99
3 days, 16 hours ago -
How do I migrate Password Managers
by
Rush2112
3 days ago -
Orb : how fast is my Internet connection
by
Alex5723
3 days, 2 hours ago -
Solid color background slows Windows 7 login
by
Alex5723
4 days, 5 hours ago -
Windows 11, version 24H2 might not download via Windows Server Updates Services
by
Alex5723
4 days, 3 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.