Solved Email current record for form

KarimR

New member
Local time
Today, 05:32
Joined
Oct 27, 2025
Messages
4
Hi All

I very new to MS Access. I have built a database for me a record any repairs that a tenant requires. I want to be able to email a contractor the record I have just created.

The following code works but it pdf’s the whole form.


DoCmd.SendObject acSendForm, "frm_repairs", acFormatPDF, Forms!frm_repairs!ContractorEmail, , , _

"Repairs Requested ", "Please find attached repairs requested by the tenant."


I would be grateful for any suggestions
 
As Gasman says, you need a report that formats the work order exactly as you want to send it to the contractor. It can be similar to the appearance of the form, but will probably be quite different -- based on your description of the problem.

For the report, create a query with a WHERE clause that matches the WHERE clause for the form's recordsource so your report includes the same selected records.

Create and email a PDF from the report.
 
there is a display when property for controls
1761656190160.png


So you can set to screen only (and use the can grow/shrink properties if required, they only work when printing the form)

and of course you might have a control you want to show when printing, but not on the screen

All depends on how your form would look with various controls hidden
 
As an option, you can create your "Repairs" as a text string. You would then pass your string as the last parameter.
This would allow you to skip creating an attachment. Something like

strBody = "Tenant " & frm_repairs.Tenant & " in building " & frm_repairs.TenantAddress & vbCrLf & _
"Requests the following repairs" & vbCrLf & frm_repairs.TxtRepairs

Were it me, I'd do this even if you are still including a form. Met too many people who can't be bothered to open an attachment on their phone but have no problem reading the email.
 
Hi All

I very new to MS Access. I have built a database for me a record any repairs that a tenant requires. I want to be able to email a contractor the record I have just created.

The following code works but it pdf’s the whole form.


DoCmd.SendObject acSendForm, "frm_repairs", acFormatPDF, Forms!frm_repairs!ContractorEmail, , , _

"Repairs Requested ", "Please find attached repairs requested by the tenant."


I would be grateful for any suggestions
Can you upload a copy of the Db?
 
One way
Code:
Private Sub Command31_Click()
        Me.Filter = "RepairsID =" & Me.RepairsID
        Me.FilterOn = True
       DoCmd.SendObject acSendForm, "frm_repairs", acFormatPDF, Forms!frm_repairs!TenantEmail, , , _
        "Repairs Requested ", "Please find attached repairs requested by You."

        Me.Filter = ""
        Me.FilterOn = False



End Sub

Private Sub Command32_Click()
        Me.Filter = "RepairsID =" & Me.RepairsID
        Me.FilterOn = True
       DoCmd.SendObject acSendForm, "frm_repairs", acFormatPDF, Forms!frm_repairs!ContractorEmail, , , _
        "Repairs Requested ", "Please find attached repairs requested by The Tenant."
        Me.Filter = ""
        Me.FilterOn = False


End Sub

Might want to do them both at the same time?
 
Last edited:
Here is the db
Hi Karim

Your tables have some design issues.
You should not use Lookup Fields in table. Check Google for "The Evils of Lookup fields in Access Tables"
You have not set referential integrity between tables.
You should not set the Format of your Autonumbers to 000
You should not set the record source of your frm_Repairs using a query based on 3 tables.
You should have a Main form based on Contractors and a Subform based on Repairs.
 
One way
Code:
Private Sub Command31_Click()
        Me.Filter = "RepairsID =" & Me.RepairsID
        Me.FilterOn = True
       DoCmd.SendObject acSendForm, "frm_repairs", acFormatPDF, Forms!frm_repairs!TenantEmail, , , _
        "Repairs Requested ", "Please find attached repairs requested by You."

        Me.Filter = ""
        Me.FilterOn = False



End Sub

Private Sub Command32_Click()
        Me.Filter = "RepairsID =" & Me.RepairsID
        Me.FilterOn = True
       DoCmd.SendObject acSendForm, "frm_repairs", acFormatPDF, Forms!frm_repairs!ContractorEmail, , , _
        "Repairs Requested ", "Please find attached repairs requested by The Tenant."
        Me.Filter = ""
        Me.FilterOn = False


End Sub

Might want to do them both at the same time?
That is amazing, thank you very much Gasman it does what I want it to. I want to build this db to do a lot more but one step at a time.
 
Give your controls meaningful names. Command32 is not going to mean anything in a month or two.
 

Users who are viewing this thread

Back
Top Bottom