Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting table contents into a string 1

Status
Not open for further replies.

vacant

Technical User
Aug 5, 2001
35
0
0
GB
I have an access2000 database that emails an XL file to various people at the press of a button, using the following simple code…

DoCmd.SendObject acQuery, "qry_GMC_Name", acFormatXLS, recipient, , , "Supplementary list update", msgText, editMsg

The string variable ‘recipient’ is the list of recipients which, at present, I have simply declared and assigned within the code.
However, this list is becoming quite large and, in order to make it more manageable, the addresses would ideally reside in a table which could then be converted into a single-line string that could be used in this function.
Unfortunately I’m still pretty new at this, and am at present clueless when it comes to working with Recordsets etc.
Would some kind soul give me some guidance on how to do this, please?
 
This is just an example, the following code moves through the table called tbl and uses the field TABLE_NAME to step through each table's name (linking them to the database). You could adapt this as the key bit is the loop.

Private Sub Command0_Click()

Dim db As DAO.Database
Dim rsTable As DAO.Recordset
Dim nCount

nCount = 1
Set db = CurrentDb
Set rsTable = db.OpenRecordset("tbl")
rsTable.MoveFirst
Do While Not rsTable.EOF
DoCmd.TransferDatabase acLink, "ODBC", "ODBC;DSN=geneva_for_cw;UID=train1;PWD=train1;SERVER=GENEVA-EAG;", acTable, "TRAIN1." & rsTable![TABLE_NAME], "TRAIN1." & rsTable![TABLE_NAME], False
rsTable.MoveNext
Loop
End Sub
 
Fantastic, working like a treat
- Here, have a star
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top