Hi guys,
having problems using fields from subforms in event procedures for button clicks etc. I'm not great with VBA, but I am learning...
example below, is supposed to take email address from a subform(sfrm_emails) to use in emailing report by sendobject.
Private Sub send_report_Click()
On Error GoTo Err_send_report_Click
Dim to_list As String
Dim subject As String
Dim msgText As String
subject = "report_" & Forms![frm_send report].[report_ID]
msgText = "Dear Sirs, please find attached report"
to_list = Forms.[sfrm_emails].[DXEMAL] & ";" & Forms.[sfrm_emails].[DCEMAL]
If IsNull(Forms.frm_report.Date_Open) Then
MsgBox ("You have not set a Date Raised; you must do this before you can raise a report")
End If
If (Forms.frm_report.Date_Open) > 1 Then
DoCmd.SendObject acReport, "rpt_report", "Rich Text Format (*.rtf)", to_list, , , subject, msgText
End If
Exit_send_report_Click:
Exit Sub
Err_send_report_Click:
MsgBox Err.Description
Resume Exit_send_report_Click
End Sub
why doesn't this work? If the email addresses were on the form, it works, but why not from subform?
Alternatively, what would the vb be to fill two text boxes (unbound) with the addresses and then email to those?
Also been attempting to use fields in subforms for arguements in event procedures and it isn't working. I'm guessing i'm not referencing the fields correctly, but can't see how!
I'm stuck, please help!
Thanks, Rob
having problems using fields from subforms in event procedures for button clicks etc. I'm not great with VBA, but I am learning...
example below, is supposed to take email address from a subform(sfrm_emails) to use in emailing report by sendobject.
Private Sub send_report_Click()
On Error GoTo Err_send_report_Click
Dim to_list As String
Dim subject As String
Dim msgText As String
subject = "report_" & Forms![frm_send report].[report_ID]
msgText = "Dear Sirs, please find attached report"
to_list = Forms.[sfrm_emails].[DXEMAL] & ";" & Forms.[sfrm_emails].[DCEMAL]
If IsNull(Forms.frm_report.Date_Open) Then
MsgBox ("You have not set a Date Raised; you must do this before you can raise a report")
End If
If (Forms.frm_report.Date_Open) > 1 Then
DoCmd.SendObject acReport, "rpt_report", "Rich Text Format (*.rtf)", to_list, , , subject, msgText
End If
Exit_send_report_Click:
Exit Sub
Err_send_report_Click:
MsgBox Err.Description
Resume Exit_send_report_Click
End Sub
why doesn't this work? If the email addresses were on the form, it works, but why not from subform?
Alternatively, what would the vb be to fill two text boxes (unbound) with the addresses and then email to those?
Also been attempting to use fields in subforms for arguements in event procedures and it isn't working. I'm guessing i'm not referencing the fields correctly, but can't see how!
I'm stuck, please help!
Thanks, Rob