![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, I have an Access database and I want to populate a memo/text field with a string of values retrieved from the database based upon a particular value. So for example I want to populate the field with a string of the names of other contacts at the same company as the current contact separated by a comma. I'm not sure how to go about this? Should I use Visual Basic or a query or a combination of both. Any suggestions or sample code would be very helpful. Thanks Emmett Power |
#3
| |||
| |||
|
|
"Emmett Power" <Emmett (AT) Silico-Research (DOT) com> wrote in message news:6e11de5c.0309230808.4819f4c2 (AT) posting (DOT) google.com... Hi, I have an Access database and I want to populate a memo/text field with a string of values retrieved from the database based upon a particular value. So for example I want to populate the field with a string of the names of other contacts at the same company as the current contact separated by a comma. I'm not sure how to go about this? Should I use Visual Basic or a query or a combination of both. Any suggestions or sample code would be very helpful. Thanks Emmett Power You can use a simple bit of code to loop through records and build a string which you then put into your memo field. It might look something like: If Not rsCompany.EOF then rsCompany.MoveFirst 'If records exist move first Do Until rsCompany.EOF strCriteria = "[CompanyID]=" & rsCompany![CompanyID] varContacts = Null 'Clear each time through rsContacts.FindFirst strCriteria Do Until rsContacts.NoMatch if Len(Contacts) > 0 then Contacts = Contacts & ", " 'Only add comma if text exists varContacts = Contacts & rsContacts![ContactName] rsContacts.FindNext strCriteria Loop With rsCompany .Edit ![ContactList] = varContacts .Update .MoveNext End With Loop |
#4
| |||
| |||
|
|
"Emmett Power" <Emmett (AT) Silico-Research (DOT) com> wrote in message news:6e11de5c.0309230808.4819f4c2 (AT) posting (DOT) google.com... Hi, I have an Access database and I want to populate a memo/text field with a string of values retrieved from the database based upon a particular value. So for example I want to populate the field with a string of the names of other contacts at the same company as the current contact separated by a comma. I'm not sure how to go about this? Should I use Visual Basic or a query or a combination of both. Any suggestions or sample code would be very helpful. Thanks Emmett Power You can use a simple bit of code to loop through records and build a string which you then put into your memo field. It might look something like: If Not rsCompany.EOF then rsCompany.MoveFirst 'If records exist move first Do Until rsCompany.EOF strCriteria = "[CompanyID]=" & rsCompany![CompanyID] varContacts = Null 'Clear each time through rsContacts.FindFirst strCriteria Do Until rsContacts.NoMatch if Len(Contacts) > 0 then Contacts = Contacts & ", " 'Only add comma if text exists varContacts = Contacts & rsContacts![ContactName] rsContacts.FindNext strCriteria Loop With rsCompany .Edit ![ContactList] = varContacts .Update .MoveNext End With Loop -- Bradley Software Developer www.hrsystems.com.au A Christian Response www.pastornet.net.au/reponse |
#5
| |||
| |||
|
|
Hi, I have an Access database and I want to populate a memo/text field with a string of values retrieved from the database based upon a particular value. So for example I want to populate the field with a string of the names of other contacts at the same company as the current contact separated by a comma. I'm not sure how to go about this? Should I use Visual Basic or a query or a combination of both. Any suggestions or sample code would be very helpful. Thanks Emmett Power |
![]() |
| Thread Tools | |
| Display Modes | |
| |