Re: list box items
From: Steve Schapel (schapel_at_mvps.org.ns)
Date: 03/06/05
- Next message: Marshall Barton: "Re: Set control source =[cbxName].column(2)"
- Previous message: Steve Schapel: "Re: launch form from list box criteria"
- In reply to: Russ: "list box items"
- Next in thread: Russ: "Re: list box items"
- Reply: Russ: "Re: list box items"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 06 Mar 2005 16:01:22 +1300
Russ,
You could write a User-Defined Function in a standard module, and then
use this in your query. Something like this (caution: air code!)...
Public Function ListMeds(TheSSN As String) As String
Dim rst As Dao.Recordset
Dim MedsList As String
Set rst = CurrentDb.OpenRecordset("SELECT SSN, Medication FROM
SecondTable WHERE SSN='" & TheSSN & "'")
With rst
Do Until .EOF
MedsList = MedsList & ![Medication] & ", "
Loop
End With
ListMeds = Left(MedsList, Len(MedsList) - 2)
End Function
Then, in your query, make a calculated field like this:
PatientMeds: ListMeds([SSN])
-- Steve Schapel, Microsoft Access MVP Russ wrote: > I have a list box in a form. the list box is unbound. it displays a list of > medications for a patient. 2 tables are involved. the first table is > demographics, which the SSN comes from. teh second table has SSN and the > medication. the second table has several records for each patient, one > record for each medication. > > i can get all the medications into the list box in teh form. but i now need > to put these all into one field of a query or table so that i can use them in > a mail merge with word. i must use mail merge so i can send a letter to > referring physician. how do i get these into one field. i would like them > all to be seperated by commas if possible. > > thank you, > russ
- Next message: Marshall Barton: "Re: Set control source =[cbxName].column(2)"
- Previous message: Steve Schapel: "Re: launch form from list box criteria"
- In reply to: Russ: "list box items"
- Next in thread: Russ: "Re: list box items"
- Reply: Russ: "Re: list box items"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|