J
Jack W via AccessMonster.com
Hi,
I've got a query which has payment information for our brokers for all of our
accounts. The first field is the broker name, I have a table with these
stored also with their corresponding email addresses. Currently, I select the
broker from a combo box on my form to view payments to that broker. I've then
got a sendobject code which I want to email the payments to that broker for
the day. The problem is, I don't know how to make it populate the email
address from my table automatically when I run the code. I thought DLookup
would work to select the recipient but it's not working, any ideas?
Here's what I've got:
Function EmailCalls()
On Error GoTo EmailCalls_Err
Dim Receipient As String
strReceipient = DLookup("[Address]", "tblFCMs", "[Forms]![Futures
Database]![callfcm]![Address]=[tblFCMs]![Address]")
DoCmd.SendObject acQuery, "qryMarginCalls", "MicrosoftExcelBiff8(*.xls)",
strReceipient, "", "", "Test", _
strMessage1, True, ""
MsgBox "Email Sent Successfully - Margin Calls Advised", vbInformation,
"Email Status"
EmailCalls_Exit:
Exit Function
EmailCalls_Err:
MsgBox "Email has not been Sent", vbInformation, "Email Status"
Resume EmailCalls_Exit
End Function
I've got a query which has payment information for our brokers for all of our
accounts. The first field is the broker name, I have a table with these
stored also with their corresponding email addresses. Currently, I select the
broker from a combo box on my form to view payments to that broker. I've then
got a sendobject code which I want to email the payments to that broker for
the day. The problem is, I don't know how to make it populate the email
address from my table automatically when I run the code. I thought DLookup
would work to select the recipient but it's not working, any ideas?
Here's what I've got:
Function EmailCalls()
On Error GoTo EmailCalls_Err
Dim Receipient As String
strReceipient = DLookup("[Address]", "tblFCMs", "[Forms]![Futures
Database]![callfcm]![Address]=[tblFCMs]![Address]")
DoCmd.SendObject acQuery, "qryMarginCalls", "MicrosoftExcelBiff8(*.xls)",
strReceipient, "", "", "Test", _
strMessage1, True, ""
MsgBox "Email Sent Successfully - Margin Calls Advised", vbInformation,
"Email Status"
EmailCalls_Exit:
Exit Function
EmailCalls_Err:
MsgBox "Email has not been Sent", vbInformation, "Email Status"
Resume EmailCalls_Exit
End Function