I don't know if this is possible, but I want to try to send a report by email by clicking a command button on a form. My problem is that the name of the report is determined by the value of another variable in the form. The form has a pull-down menu of names called "Assigned to:" and I want the button to send the report that has the same name as the value of "Assigned to:" to the person who's name is "Assigned to:". Is there a way to program a command button to have these variables and look them up from the form that the button is on?
Is your mail client Outlook? I think I know how you could do that if you use Outlook.
yes, I am using Outlook...
Hoa Le
05-10-2000, 12:52 PM
Create a form with a button cmdSend and a textbox named txtRecipient. Next, behind the OnClick event of the button, paste this code:
'-----------------------------
Private Sub cmdSend_Click()
Dim strRecipient As String
On Error GoTo cmdSend_Click_Err
strRecipient = Me.txtRecipient
DoCmd.SendObject , "Attachment here!", "Format here!", strRecipient, "", "", "Subject heading here!", "Your message here!", True, ""
cmdSend_Click_Exit:
Exit Sub
cmdSend_Click_Err:
MsgBox Error$
Resume cmdSend_Click_Exit
End Sub
'--------------------------------
Enter a name in the textbox and click the button to send your e-mail to that name.
Good luck.
Thanx! It worked great...!