Type mismatch error

K

Kevin Bruce

On a form, I have placed a command button that opens the user's email client
and places the email address from records in a query into the 'To' line. The
process works fine in a copy of the database that I was working in to
develop this, but when imported into the original database I get a 'Type
mismatch error' when I attempt to run it. The highlighted error line is:

"Set recEvents = db.OpenRecordset(strQuery)".

All of the references in the data library are the same in both the copy and
the original.

Any help would be appreciated.

Below is my code for the command button in its entirety.

Thanks.

_Kevin


Private Sub cmdSendEmail_Click()

Me.Refresh

Dim strQuery As String
strQuery = "qryMyQuery"

Dim strTo As String
Dim db As Database
Dim recEvents As Recordset

Set db = CurrentDb()
Set recEvents = db.OpenRecordset(strQuery)


While Not recEvents.EOF
strTo = recEvents("Email") & ";" & strTo
recEvents.MoveNext
Wend

DoCmd.SendObject acSendNoObject, , , strTo, , , , , , True

End Sub

--
================================
Kevin Bruce
Program Coordinator
ArtStarts in Schools
301 - 873 Beatty Street
Vancouver, BC V6B 2M6

ph:604-878-7144 ext.3
fx: 604-683-0501

web: www.artstarts.com

Did you know that you can donate to ArtStarts in Schools directly from our
website? www.artstarts.ca
 
G

Guest

Hi, Kevin.
All of the references in the data library are the same in both the copy and
the original.

They may be the same, but the precedence order doesn't match verbatim.
Either change the precedence so that the DAO library is before the ADO
library or change the following line of code so that the Recordset variable
is disambiguated:

Dim recEvents As Recordset

to:

Dim recEvents As DAO.Recordset

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)

- - -
When you see correct answers to your question posted in Microsoft's Online
Community, please sign in to the Community and mark these posts as "Answers,"
so that all may benefit by filtering on "Answered questions" and quickly
finding the right answers to similar questions. (Only "Answers" have green
check-marks.) Remember that the best answers are often given to those who
have a history of rewarding the contributors who have taken the time to
answer questions correctly.
 
K

Kevin Bruce

Thanks for the quick response. I had no idea that there was an order of
precedence among the various libraries. Very useful to know.

_Kevin
 
G

Guest

You're welcome. For more information on the ADO and DAO library ambiguation
problem, please see Tom Wickerath's tip, "ADO and DAO Library References in
Access Databases" on the following Web page:

http://www.Access.QBuilt.com/html/gem_tips1.html

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)

- - -
When you see correct answers to your question posted in Microsoft's Online
Community, please sign in to the Community and mark these posts as "Answers,"
so that all may benefit by filtering on "Answered questions" and quickly
finding the right answers to similar questions. (Only "Answers" have green
check-marks.) Remember that the best answers are often given to those who
have a history of rewarding the contributors who have taken the time to
answer questions correctly.
 

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

Similar Threads


Top