A
ad
Hi
This must be another easy one for you guys:
I am trying to read all email addresses in a table into a string variable using "getrows".
I have searched the Internet for a few days and couldn't get it work for me. the following
is the code I come up with. It doesn't work. It stops at OpenRecordset saying type
missmatch.
Please help......
ad
=============================
Sub test()
Dim db As Database
Dim Lrs As Recordset
Dim LSQL As String
Dim email As Variant
Dim c As Integer
Dim strEmail As String
'Open connection to current Access database
Set db = CurrentDb()
'Create SQL statement to retrieve value from GST table
LSQL = "SELECT Contacts.[E-Mail Address] FROM MailingList INNER JOIN Contacts ON MailingList.ContactID = Contacts.[Contact ID];"
Set Lrs = db.OpenRecordset(LSQL)
email = Lrs.GetRows
For c = 1 To 2
strEmail = strEmail & email(c) & "; "
Next c
' Display the results.
MsgBox strEmail
Lrs.Close
Set Lrs = Nothing
End Sub
This must be another easy one for you guys:
I am trying to read all email addresses in a table into a string variable using "getrows".
I have searched the Internet for a few days and couldn't get it work for me. the following
is the code I come up with. It doesn't work. It stops at OpenRecordset saying type
missmatch.
Please help......
ad
=============================
Sub test()
Dim db As Database
Dim Lrs As Recordset
Dim LSQL As String
Dim email As Variant
Dim c As Integer
Dim strEmail As String
'Open connection to current Access database
Set db = CurrentDb()
'Create SQL statement to retrieve value from GST table
LSQL = "SELECT Contacts.[E-Mail Address] FROM MailingList INNER JOIN Contacts ON MailingList.ContactID = Contacts.[Contact ID];"
Set Lrs = db.OpenRecordset(LSQL)
email = Lrs.GetRows
For c = 1 To 2
strEmail = strEmail & email(c) & "; "
Next c
' Display the results.
MsgBox strEmail
Lrs.Close
Set Lrs = Nothing
End Sub