Pardon me for dropping in, but perhaps what we are looking for is something
like the following. Note that this query cannot use the query design view,
but must be done in the SQL view (the non-equi join causes this problem).
SELECT boston.Boston, Name_Address.ZIP, Name.MEMBER_TYPE, Name.CATEGORY,
Name.STATUS, Name.PREFIX, Name.FIRST_NAME, Name.TITLE, Name.COMPANY,
Name_Address.ADDRESS_1, Name_Address.ADDRESS_2, Name_Address.CITY,
Name_Address.STATE_PROVINCE, Name_Address.ZIP, Name.WORK_PHONE, Name.EMAIL,
dbo_Demographics.NO_MAIL, dbo_Demographics.NO_EMAIL
FROM (([Name]INNER JOIN Name BOSTON ON Name.ZIP LIKE (boston.Boston & "*"))
INNER JOIN
Name_Address ON Name.MAIL_ADDRESS_NUM = Name_Address.ADDRESS_NUM) LEFT JOIN
dbo_Demographics ON Name.ID = dbo_Demographics.ID
WHERE ((
((Name.MEMBER_TYPE)="MK" Or (Name.MEMBER_TYPE)="pi") AND ((Name.STATUS)="A"
Or (Name.STATUS)="I") AND ((dbo_Demographics.NO_MAIL)<>1) AND
((dbo_Demographics.NO_EMAIL)<>1));
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
thanks again Kaltuu.
It's still not giving me any reocords with zip +4. Below is the sql view.
Perhaps you can see where (not pun intended) I'm making my mistake?
Boston excel is the 5 digit zip single field named boston
Name has the member code and status
Name_address has the full postal address with zip+4 for the preferred address
Demographics has opt-out options
SELECT boston.Boston, Name_Address.ZIP, Name.MEMBER_TYPE, Name.CATEGORY,
Name.STATUS, Name.PREFIX, Name.FIRST_NAME, Name.TITLE, Name.COMPANY,
Name_Address.ADDRESS_1, Name_Address.ADDRESS_2, Name_Address.CITY,
Name_Address.STATE_PROVINCE, Name_Address.ZIP, Name.WORK_PHONE, Name.EMAIL,
dbo_Demographics.NO_MAIL, dbo_Demographics.NO_EMAIL
FROM ((boston INNER JOIN Name ON boston.Boston = Name.ZIP) INNER JOIN
Name_Address ON Name.MAIL_ADDRESS_NUM = Name_Address.ADDRESS_NUM) LEFT JOIN
dbo_Demographics ON Name.ID = dbo_Demographics.ID
WHERE (((boston.Boston) Like [name_address].[zip] & "*") AND
((Name.MEMBER_TYPE)="MK" Or (Name.MEMBER_TYPE)="pi") AND ((Name.STATUS)="A"
Or (Name.STATUS)="I") AND ((dbo_Demographics.NO_MAIL)<>1) AND
((dbo_Demographics.NO_EMAIL)<>1));
Thanks
John
Klatuu said:
It isn't a Link, it is criteria in a Where clause. You can set it up in the
query builder.
In the column for the zip5 in the linked excel sheet in the Criteria row,
type in:
Like [nameaddresses].[zipfieldname] & "*"
--
Dave Hargis, Microsoft Access MVP
:
Thanks Klatuu,
That's the part I don't know how to do.
I'm not very versed in Access-Query
The way I've set this query up is:
I'm linking the zip5 excel file to the nameaddress table via the zip to zip
- join type
1 (there are 40+zipcodes in the zip5 excel files)
The only time I've used like is in the criteral when I'n only using the
nameaddress table and then I'd type in all the likes manually - though
usually there are only 4 or 5 zips. This time the 40+ makes that impractical
for a novis like me.
How do I link the zip5 excel to the nameaddress and tell the nameaddress to
pull all records that have a zip that starts with the first 5 digits of the
zip5 field?
:
it would be easier to use:
Like Zip5 & "*"
It will then find all matching 5 digits and all that start with the 5 digit
code.
--
Dave Hargis, Microsoft Access MVP
:
I found this response in a post regarding a query I'm trying to do. It looks
like it's what I need but I don't know how/were to implement it in the query.
what I found
Hi,
do you have these zip codes stored already? Then just use this in your
criteria:
Left ([YourField], 3)
If not than create a zip code table and include the zipcode field in the
query. Then set the criteria similar.
HTH
Good luck
I have a table(excel file) of 5 digit zipcodes.
I'm linking it to a name-address table that has a 9 digit zip.
I only find records with the exact 5 digit match - not the many that have +4
How/where do I add the left(yourfiled,5) above.
I've always done this by adding a like function in the zip filed for all the
zips I need but the above method would be much clearner and easier - assuming
I can learn how to do it.
Thanks
John