L
LDMueller
I have a query named "qryEmailList" which consists of two related tables as
follows:
INVENTOR.InvName
INVENTOR.Email
INVENTORLIST.InvMtr
My code is as follows. This code runs a query named "qryEmailList" and
pulls the email address from each record so I can email the list. All works
fine, however, I need to add criteria to this query based on Inventor number.
If I put a specific Inventor number in the criteria field of the query
itself, all works. If I put the prompt "Like "*" & [Enter Inventor Number]"
in the criteria field of the query itself it doesn't work and I need it to
prompt so I can enter the Inventor Number.
Based on this I assume I need to be able to add VBA code which puts the
criteria prompt "Like "*" & [Enter Inventor Number]" in the field
INVENTORLIST.InvMtr
Private Sub cmdEmailAll_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim sAddress As String
Set db = CurrentDb()
Set rs = db.OpenRecordset("Select Email From qryEmailList")
With rs
If (Not .BOF) And (Not .EOF) Then
.MoveFirst
sAddress = .Fields("Email")
.MoveNext
End If
If (Not .BOF) And (Not .EOF) Then
Do Until .EOF
sAddress = sAddress & "; " & .Fields("Email")
.MoveNext
Loop
End If
.Close
End With
DoCmd.SendObject , , acFormatTXT, sAddress, , , , , -1
End Sub
If anyone can help me with this or give me advise on going in another
direction I would sincerely appreciate it.
Thanks,
LDMueller
follows:
INVENTOR.InvName
INVENTOR.Email
INVENTORLIST.InvMtr
My code is as follows. This code runs a query named "qryEmailList" and
pulls the email address from each record so I can email the list. All works
fine, however, I need to add criteria to this query based on Inventor number.
If I put a specific Inventor number in the criteria field of the query
itself, all works. If I put the prompt "Like "*" & [Enter Inventor Number]"
in the criteria field of the query itself it doesn't work and I need it to
prompt so I can enter the Inventor Number.
Based on this I assume I need to be able to add VBA code which puts the
criteria prompt "Like "*" & [Enter Inventor Number]" in the field
INVENTORLIST.InvMtr
Private Sub cmdEmailAll_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim sAddress As String
Set db = CurrentDb()
Set rs = db.OpenRecordset("Select Email From qryEmailList")
With rs
If (Not .BOF) And (Not .EOF) Then
.MoveFirst
sAddress = .Fields("Email")
.MoveNext
End If
If (Not .BOF) And (Not .EOF) Then
Do Until .EOF
sAddress = sAddress & "; " & .Fields("Email")
.MoveNext
Loop
End If
.Close
End With
DoCmd.SendObject , , acFormatTXT, sAddress, , , , , -1
End Sub
If anyone can help me with this or give me advise on going in another
direction I would sincerely appreciate it.
Thanks,
LDMueller