B
bymarce
I have a form called "WorkAssginments". There are unbound combo boxes at the
top that are used to build the form's filter. I want to use the forms filter
to select email addresses from a table that is related to the table table
onwhich the form is built. The form "WorkAssignments" is based on the data
table and has a field "AssignedTo" that is related to "Initials" in the
personel Table. One post I read said to build a query to select the email
adresses and use it in the following code. When click the button to run this
code I get error 3061 "Too Few Parameters. Expected 1" and the Set rst =
db.OpenRecordset("qryEmails") line is highlighted. How can I get this to
work or is there a way to use the filter that is already built in the form
rather than a seperate query? Thanks.
Marcie
Private Sub Email_Work_Click()
Dim SendTo As String
Dim rst As dao.Recordset
Dim db As dao.Database
Set db = CurrentDb()
Set rst = db.OpenRecordset("qryEmails")
With rst
If Not .BOF And .EOF Then
Do Until .EOF
SendTo = SendTo & .Fields("Email") & "; "
.MoveNext
Loop
End If
.Close
End With
Dim strWhere As String
If Me.FilterOn Then
strWhere = Me.Filter
End If
Debug.Print strWhere
Dim MySubject As String, MyMessage As String
MySubject = Me.MLO
MyMessage = "Please complete the following tests for " & Me.MLO & "."
DoCmd.SendObject acSendReport, "rptWorkAssignments",
"SnapshotFormat(*.snp)", SendTo, "(e-mail address removed)", , MySubject,
MyMessage, True
End Sub
top that are used to build the form's filter. I want to use the forms filter
to select email addresses from a table that is related to the table table
onwhich the form is built. The form "WorkAssignments" is based on the data
table and has a field "AssignedTo" that is related to "Initials" in the
personel Table. One post I read said to build a query to select the email
adresses and use it in the following code. When click the button to run this
code I get error 3061 "Too Few Parameters. Expected 1" and the Set rst =
db.OpenRecordset("qryEmails") line is highlighted. How can I get this to
work or is there a way to use the filter that is already built in the form
rather than a seperate query? Thanks.
Marcie
Private Sub Email_Work_Click()
Dim SendTo As String
Dim rst As dao.Recordset
Dim db As dao.Database
Set db = CurrentDb()
Set rst = db.OpenRecordset("qryEmails")
With rst
If Not .BOF And .EOF Then
Do Until .EOF
SendTo = SendTo & .Fields("Email") & "; "
.MoveNext
Loop
End If
.Close
End With
Dim strWhere As String
If Me.FilterOn Then
strWhere = Me.Filter
End If
Debug.Print strWhere
Dim MySubject As String, MyMessage As String
MySubject = Me.MLO
MyMessage = "Please complete the following tests for " & Me.MLO & "."
DoCmd.SendObject acSendReport, "rptWorkAssignments",
"SnapshotFormat(*.snp)", SendTo, "(e-mail address removed)", , MySubject,
MyMessage, True
End Sub