User-defined type not found error

M

Me

Hello,

I am trying to access set of records in a query sequentially to send
email. I have the following code to access a query.
*****
Sub ReadRecords()
Dim dbsTemp As DATABASE
Dim rst As Recordset
Dim intRowCount As Integer

Set dbsTemp = CurrentDb()
Set rst = dbsTemp.OpenRecordset("QrySearchForEmail")

If rst.RecordCount = 0 Then
MsgBox "There are no records in the error table", vbInformation
GoTo ExtractErrors_exit
End If
ExtractErrors_exit:
rst.Close
Set rst = Nothing
Set dbsTemp = Nothing
Exit Sub
**************
However, I get error "User-defined type not found" error for 'DATABASE'
I also tried using DAO.DATABASE, but get the same error?

1. How can I resolve this error?
2. Is there a beter way to send mass email for a list of emailid from a table?

Thank you in advance,
-Me


End Sub
 
O

Ofer Cohen

Open code (anywhere), from the menu select Tools -> Reference

Check if Microsoft DAO 3.6 Object library is selected,
if not select it.

Also, it safer to specify in the code what you are using:

Dim dbsTemp As Dao.DATABASE
Dim rst As Dao.Recordset
 
M

Me

Hello Ofer,

I selected 'Microsoft DAO 3.6', still I get the same error.
I also tried selecting Microsoft DAO3.5, but I continue to get
the same errror.

Any other idea?

Thank you,
-Me
 
O

Ofer Cohen

Did you try declaring the database and recordset as

Dim dbsTemp As Dao.DATABASE
Dim rst As Dao.Recordset
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top