This works in 2000, doesn't in 2002 ???

tfaiers

Registered User.
Local time
Today, 06:40
Joined
Apr 26, 2002
Messages
54
I'm using the following code taken from one of the posts on the forum (thanks to whoever wrote it - can't think of the user at the moment)

It works in Access 2000, but keeps failing in Access 2002 with a 'type mismatch' error, any reasons why this code doesn't work???

It basically scans through the record list and compiles a bulk e-mail list and passes it to Outlook and no it's not for spam mail!

The line that errors is - "Set rst = CurrentDb.OpenRecordset(stSQL)"

Private Sub Command165_Click()
Dim rst As Recordset
Dim stSQL As String
Dim stTO As String

stSQL = "Clients"

Set rst = CurrentDb.OpenRecordset(stSQL)
With rst
.MoveFirst
Do While Not .EOF
stTO = stTO & IIf(stTO <> "", ";", "") & .Fields("E-Mail Address")

.MoveNext
Loop
End With

DoCmd.SendObject acSendNoObject, , , , , stTO, "Information Requested", , True

End Sub

Thanks everyone :-)
 
You have to make sure that DAO 3.6 is set in the Reference. When you are in VB Editor, go to Tools menu>References>look for if the Microsoft DAO Object Lib. 3.6 is selected. If not, scroll down and find it.

If the DAO is set, then you have to explicitly dim your variables.

...
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim stSQL As String
Dim stTO As String

stSQL = "Clients"

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(stSQL)
...
 

Users who are viewing this thread

Back
Top Bottom