K
Kevin Bruce
A problem with QueryDefs...
I send out email reminders on a monthly basis to school districts. To this
end, I have created a form (called 'frmSDMonthlyReminder') with a button
(cmdButton) and a combo box (cboSD). The button, when clicked, opens the
email client and adds all the necessary addresses and infomation drawn from
a variety of queries (eg. 'qryBookingEmailSDContact'). The combo box
contains a list of the specific school districts that are intended to limit
the query.
When I click the button I get this message:
Item not found in this collection. (Error 3265)
I am uncertain as to how to correct this error. Below is the first part of
my code with the line where it stops running marked with asterisks (***).
Thanks in advance for any help.
_Kevin
==============================
Option Compare Database
Private Sub cmdButton_Click()
'create variables
Dim strTo As String
Dim strCC As String
Dim strBCC As String
Dim strSubjectLine As String
Dim strMessageText As String
Dim strEvents As String
Dim strQuery As String
Dim db As Database
Dim recEvents As Recordset
Dim qdf As QueryDef
'assign a value to the database variable
Set db = CurrentDb()
'create the addresses for the 'To' line of the email
strQuery = "qryBookingEmailSDContact"
'assign a value to the query parameters
Set qdf = db.QueryDefs(strQuery)
*** qdf.Parameters(0) = Forms!frmSDMonthlyReminder!cboSD ***
Set recEvents = db.OpenRecordset(strQuery)
While Not recEvents.EOF
strTo = recEvents("email") & ";" & strTo
recEvents.MoveNext
Wend
I send out email reminders on a monthly basis to school districts. To this
end, I have created a form (called 'frmSDMonthlyReminder') with a button
(cmdButton) and a combo box (cboSD). The button, when clicked, opens the
email client and adds all the necessary addresses and infomation drawn from
a variety of queries (eg. 'qryBookingEmailSDContact'). The combo box
contains a list of the specific school districts that are intended to limit
the query.
When I click the button I get this message:
Item not found in this collection. (Error 3265)
I am uncertain as to how to correct this error. Below is the first part of
my code with the line where it stops running marked with asterisks (***).
Thanks in advance for any help.
_Kevin
==============================
Option Compare Database
Private Sub cmdButton_Click()
'create variables
Dim strTo As String
Dim strCC As String
Dim strBCC As String
Dim strSubjectLine As String
Dim strMessageText As String
Dim strEvents As String
Dim strQuery As String
Dim db As Database
Dim recEvents As Recordset
Dim qdf As QueryDef
'assign a value to the database variable
Set db = CurrentDb()
'create the addresses for the 'To' line of the email
strQuery = "qryBookingEmailSDContact"
'assign a value to the query parameters
Set qdf = db.QueryDefs(strQuery)
*** qdf.Parameters(0) = Forms!frmSDMonthlyReminder!cboSD ***
Set recEvents = db.OpenRecordset(strQuery)
While Not recEvents.EOF
strTo = recEvents("email") & ";" & strTo
recEvents.MoveNext
Wend