Email Help!!!

  • Thread starter Jack W via AccessMonster.com
  • Start date
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
 
D

David Lloyd

Jack:

I would look at the third parameter of the DLookup function. Based on my
understanding, it seems that you want to be using the name from the combo
box to identify the correct email address to select from the table. For
example:

strReceipient = DLookup("[Address]", "tblFCMs",
"[MyNameField]=[Forms]![MyFormName]![MyComboBoxName]")

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


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
 

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

Top