dbTalk Databases Forums  

MS Access query

comp.databases.ms-access comp.databases.ms-access


Discuss MS Access query in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
vfv
 
Posts: n/a

Default MS Access query - 06-16-2010 , 12:53 PM






I have this table:
CustName TripID LocID
ABC 12 96
CBS 18 91
CSI 19 97
ABC

Reply With Quote
  #2  
Old   
Salad
 
Posts: n/a

Default Re: MS Access query - 06-16-2010 , 01:36 PM






vfv wrote:

Quote:
I have this table:
CustName TripID LocID
ABC 12 96
CBS 18 91
CSI 19 97
ABC
Cool!

Reply With Quote
  #3  
Old   
Access Developer
 
Posts: n/a

Default Re: MS Access query - 06-16-2010 , 04:06 PM



So, do you also have a question? It's not apparent from your post that you
d.

--
Larry Linson, Microsoft Office Access MVP
Co-author: "Microsoft Access Small Business Solutions", published by Wiley
Access newsgroup support is alive and well in USENET
comp.databases.ms-access


"vfv" <vfvacct (AT) gmail (DOT) com> wrote

Quote:
I have this table:
CustName TripID LocID
ABC 12 96
CBS 18 91
CSI 19 97
ABC

Reply With Quote
  #4  
Old   
James A. Fortune
 
Posts: n/a

Default Re: MS Access query - 06-16-2010 , 04:22 PM



On Jun 16, 1:53*pm, vfv <vfva... (AT) gmail (DOT) com> wrote:
Quote:
I have this table:
CustName TripID LocID
ABC * * * * * * 12 * * 96
CBS * * * * * * 18 * * 91
CSI * * * * * * * 19 * * 97
ABC
This is a shot-in-the-dark :-).

A Trip can often involve multiple locations. Perhaps you have:

tblCustomerTrips
CTID CustName TripID LocID
1 ABC 12 96
2 CBS 18 91
3 CSI 19 97
4 ABC 12 98
....

You'd like the report to show:

CBS Calgary
CSI Miami :-)
ABC Washington D.C., Dogpatch

You also have:

tblTrips
TripID TripDescription
12 Characters and Characters
18 Horses and Hockey
19 Fun in the Sun

tblLocations
LocID City StateProvince
91 Calgary Alberta
96 Washington D.C. Null
97 Miami Florida
98 Dogpatch Null

qryCustomerTripCities:
SELECT CustName, TripDescription, City FROM (tblCustomerTrips INNER
JOIN tblTrips ON tblCustomerTrips.TripID = tblTrips.TripID) INNER JOIN
tblLocations ON tblCustomerTrips.LocID = tblLocations.LocID;

!qryCustomerTripCities:
CustName TripDescription City
ABC Characters and Characters Washington D.C.
CBS Horses and Hockey Calgary
CSI Fun in the Sun Miami
ABC Characters and Characters Dogpatch

Now you have the data in a format that might support appending a list
of cities to a string using a public function such as fConcatChild().
That function was made, I think, by an Access MVP and should be
discoverable by using Google (maybe Bing also) within this newsgroup.
Note that both the CustName and TripID have to match in order to
append the City so some modification to the function might be required
(I don't remember ever using fConcatChild(), so I can't say for
sure). Subqueries can also be used to cobble together the cities, but
having a Public function append the field values to a string
(accounting for the commas correctly) is much tidier. I usually write
a function to do field concatenation as needed. The Public function
can be used in the Details section where you want the concatenated
list of cities to show up. The CustName and TripID used as parameters
in the function should be obtained from the controls in the group
headers of the report.

James A. Fortune
CDMAPoster (AT) FortuneJames (DOT) com

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.