New User - Form, Report, Most Current Record Question

  • Thread starter AnnieV via AccessMonster.com
  • Start date
A

AnnieV via AccessMonster.com

I have a form with multiple records and I want to be able to e-mail the most
current record by clicking on an “E-mail Order†command button. Using the
help I found here I added this code so I could view the most current (just
entered) record in a report:

Private Sub email_cmd_Click()
On Error GoTo Err_email_cmd_Click

Dim stDocName As String

strCriteria = "[ItemID] = " & Me!ItemID
DoCmd.OpenReport "Current Work Order Request", acViewPreview, ,
strCriteria


Exit_email_cmd_Click:
Exit Sub

Err_email_cmd_Click:
MsgBox Err.Description
Resume Exit_email_cmd_Click

End Sub

So now I can see the report with the most current record but I also want to
be able to e-mail this report when this command button is clicked….I’d really
like to just be able to get the last record and e-mail the report without the
view step. I tried adding a DoCmd.SendObject line to this but keep getting an
error. I also tried doing the e-mail via a macro step but I kept e-mailing
myself a blank version of the report. Can someone help me? What is the best
way to accomplish this?

Annie
 
G

Guest

Hi

Can you post the SendObject code you were using and also the exact wording
of the error message.
 
G

Guest

1st Copy the query the report is based on in design view
Insert this into the criteria row of the ItemID column

Forms![FormName]![ItemID]

Change the Form name to the real name of the form containing the Item ID and
the button (see below)

Save the query

Open the report in design view
Change the source to the new query you just made.
Save the report

Open the form in design view
Select the E-mail Order button
Open the button properties box
In the event column (OnClick row) insert this


Private Sub E_mail_Order_Click()
DoCmd.SendObject acReport, "Current Work Order Request",
"RichTextFormat(*.rtf)", Forms!FormName!EMailField,, "", "Your Order
Request", "Current Work Order Request Report Attached", False, ""
End Sub


In the above code change
FormName - to the real name of the form
EMailField - to the real name of the control holding the e mail address
hyperlink MailTo

The reason for applying the criteria to a new query is that I assume that
you may use the query for ofther things as well.

Hope this helps
 
A

AnnieV via AccessMonster.com

Thank you for your help. I was able to get it to work! YAY!!!!
 

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