A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Display data horizontally using concatenation



 
 
Thread Tools Display Modes
  #1  
Old December 19th, 2008, 08:49 PM posted to microsoft.public.access.gettingstarted
Dr. Lost
external usenet poster
 
Posts: 1
Default Display data horizontally using concatenation

I have subtables which list data for each patient such as

Med1
Med2
Med3

When I created the subreports, naturally the meds are listed this way. What
I want to do is have them listed this way to keep my reports from being too
long:

Med1, Med2, Med3

I have tried Duane Hookum's code, but just don't understand enough to get it
working right (eg What's DAO and ADO?). Is there a simple solution... please
help!
  #2  
Old December 19th, 2008, 08:54 PM posted to microsoft.public.access.gettingstarted
Dorian
external usenet poster
 
Posts: 542
Default Display data horizontally using concatenation

Wht not join the tables in a query which feeds your report?
Why do you have separate tables for each med?
Why not have all meds in one table that points to the patient?
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".


"Dr. Lost" wrote:

I have subtables which list data for each patient such as

Med1
Med2
Med3

When I created the subreports, naturally the meds are listed this way. What
I want to do is have them listed this way to keep my reports from being too
long:

Med1, Med2, Med3

I have tried Duane Hookum's code, but just don't understand enough to get it
working right (eg What's DAO and ADO?). Is there a simple solution... please
help!

  #3  
Old December 19th, 2008, 09:35 PM posted to microsoft.public.access.gettingstarted
Dr. Lost[_2_]
external usenet poster
 
Posts: 1
Default Display data horizontally using concatenation

Sorry, I wasn't being clear. I have a master patient table NewPatients which
contains an autonumber PatientID which is the primary key. I then have many
linked subtables: MedSubtable, PMHSubtable, FHSubtable, etc which is each
linked by Patient ID. For example, MedSubtable contains PatientID, MedID
(primary key), Med, dose, etc. When I want to generate a report that lists
this patient's history, there are subreports generated from queries using
data from the subtables and some calculated fields. The subreports come out
like this:

Meds:

med1
med2
med3

Past Medical History:

PMH1
PMH2
PMH3

I would like them to appear like this:

Meds:

med1, med2, med3, etc.

Past Medical History:

PMH1, PMH2, PMH3, etc.

I know the solution is probably simple, but it eludes me.



"Dorian" wrote:

Wht not join the tables in a query which feeds your report?
Why do you have separate tables for each med?
Why not have all meds in one table that points to the patient?
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".


"Dr. Lost" wrote:

I have subtables which list data for each patient such as

Med1
Med2
Med3

When I created the subreports, naturally the meds are listed this way. What
I want to do is have them listed this way to keep my reports from being too
long:

Med1, Med2, Med3

I have tried Duane Hookum's code, but just don't understand enough to get it
working right (eg What's DAO and ADO?). Is there a simple solution... please
help!

  #4  
Old December 19th, 2008, 09:50 PM posted to microsoft.public.access.gettingstarted
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Display data horizontally using concatenation

On Fri, 19 Dec 2008 13:35:01 -0800, Dr. Lost
wrote:

I would like them to appear like this:

Meds:

med1, med2, med3, etc.


It's not all that trivial, but not very hard. You need some VBA code to return
a concatenated string of comma separated values. See the code and instructions
at
http://www.mvps.org/access/modules/mdl0004.htm
--

John W. Vinson [MVP]
  #5  
Old December 19th, 2008, 10:00 PM posted to microsoft.public.access.gettingstarted
Steve[_57_]
external usenet poster
 
Posts: 598
Default Display data horizontally using concatenation

You need to create a function that loops through the list of Meds for the
specific patient and builds a string of all the meds.

Steve



"Dr. Lost" Dr. wrote in message
...
I have subtables which list data for each patient such as

Med1
Med2
Med3

When I created the subreports, naturally the meds are listed this way.
What
I want to do is have them listed this way to keep my reports from being
too
long:

Med1, Med2, Med3

I have tried Duane Hookum's code, but just don't understand enough to get
it
working right (eg What's DAO and ADO?). Is there a simple solution...
please
help!



  #6  
Old December 20th, 2008, 12:21 PM posted to microsoft.public.access.gettingstarted
Ken Sheridan
external usenet poster
 
Posts: 3,433
Default Display data horizontally using concatenation

All you need to do is change the subreport to an 'across then down'
multi-column layout. You'll find an example at:


http://community.netscape.com/n/pfx/...apps&tid=24271


The file also includes a code solution using a single report in which the
layout is amended by code in the report's module at runtime, but the
subreport solution is far easier. I originally produced the file in response
to a reader's enquiry in a magazine column written by a contact of mine,
merely to show that what he was asking could be done, but a subreport is the
best way to do it.

Ken Sheridan
Stafford, England

"Dr. Lost" wrote:

I have subtables which list data for each patient such as

Med1
Med2
Med3

When I created the subreports, naturally the meds are listed this way. What
I want to do is have them listed this way to keep my reports from being too
long:

Med1, Med2, Med3

I have tried Duane Hookum's code, but just don't understand enough to get it
working right (eg What's DAO and ADO?). Is there a simple solution... please
help!


 




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 Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:59 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.