Computer Learning Zone CLZ Access Excel Word Windows

Always exaggerate your estimates.

-5th Rule of Acquisition
 
Home   Courses   Seminars   Templates   TechHelp   Fast Tips   Forums   Help   Contact   Join   Order   Logon  
 
Home > TechHelp > Access >
TechHelp


Back to TechHelp
 

Join with extra conditions Upload Images   Link  
James Swanson 
21 days ago
The following appears to be correct with generic SQL syntax, however, I get an error "JOIN expression not supported" when I try to use it in Access:

SELECT Contact.*, Properties.HouseNumber & " " & Trim(Properties.DirectionPrefix & " " & Properties.Street & " " & Properties.StreetType & " " & Properties.DirectionSuffix) & Trim(" " & Properties.SuiteNo) AS Addr1, Trim(Properties.City & ", " & Properties.State & "  " & Properties.Zip) AS Addr2
FROM Contact LEFT JOIN Properties
ON Contact.Key = Properties.Contact_Key
AND "primary"=PropertyType

Any suggestions?? I only want the client's PRIMARY property to show up.
Kevin Robertson
21 days ago
The PropertyType needs to be a WHERE condition.

SELECT Contact.*, Properties.HouseNumber & " " & Trim(Properties.DirectionPrefix & " " & Properties.Street & " " & Properties.StreetType & " " & Properties.DirectionSuffix) & Trim(" " & Properties.SuiteNo) AS Addr1, Trim(Properties.City & ", " & Properties.State & "  " & Properties.Zip) AS Addr2, Properties.PropertyType
FROM Contact LEFT JOIN Properties ON Contact.Key = Properties.Contact_Key
WHERE Properties.PropertyType="Primary";


In the Query designer you can simply add "Primary" to the criteria of the PropertyType column.
James Swanson
20 days ago
That is correct and how I originally wrote it. However, this way I do not get any of the cases where a contact does not have a "primary" property. I don't always have an address for every contact. This is standard SQL and should work.

I tried something that fixed it. Access needs to group the condition with additional syntax: "FROM Contact LEFT JOIN Properties
ON (Contact.Key = Properties.Contact_Key
AND "primary"=properties.PropertyType)"

Adding the "()" helps the parser to interpret both conditions as part of the JOIN not part of the SELECT.

Thanks for your help.
James Swanson
20 days ago
OK. That's weird. When I make the change in my form and test it by executing it I get all the records as expected with NULL address info on a few records. Then, when I save it, close it, and reopen it, I get the old error message. Access won't even let me edit by clicking on the three dots in Record Source. I can review and edit within that one line and discover that Access has removed the "()" so it looks like this: "FROM Contact LEFT JOIN Properties ON Contact.Key = Properties.Contact_Key
AND "primary"=properties.PropertyType".

DO you have any suggestions how I might get this reported to Microsoft as a bug?
James Swanson
20 days ago
I fixed it by creating a query with the correct syntax and then using that query as the record source.

WHEW!
Add a ReplyUpload an Image


Back to TechHelp Comments
 

Start a NEW Conversation
 
Only students may post on this page. Click here for more information on how you can set up an account. If you are a student, please Log On first. Non-students may only post in the Visitor Forum.
 
Subscribe
Subscribe to TechHelp
Get notifications when this page is updated
 
 
 
 

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
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

Blog RSS Feed    Twitter

YouTube Channel    LinkedIn
Copyright 2023 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 3/31/2023 1:44:26 PM.