Hello, I have an email form with the code below.
I am not great at code - so this may be something obvious.
When I run the code, everything works, but the form disappears. I think it may have something to do with sending the values to the log table. To be clear the form disappears, but does not close and switching out of access and back into it then displays the form again.
Does my code need tweaking in some way to make it better. All suggestions gratefully receeived,
Many thanks Mark
Private Sub btn_send_message_DblClick(Cancel As Integer)
Dim strTest As String
strTest = TestForm()
If strTest = "" Then strTest = SendMail
If strTest = "" Then
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("log", dbOpenDynaset)
rst.AddNew
rst("log date") = Now()
rst("note") = Me.[LOG_Note]
rst("landlord log ref") = Me.[LOG_landlord_log_ref]
rst("property log ref") = Me.[LOG_property_log_ref]
rst("tenant log ref") = Me.[LOG_tenant_log_ref]
rst("landlord name") = Me.[LOG_landlord_name]
rst("property name") = Me.[LOG_property_name]
rst("tenant name") = Me.[LOG_tenant_name]
rst("contractor name") = Me.[LOG_contractor_name]
rst("Log Cheque Amount") = Me.[LOG_Log_Cheque_Amount]
rst("log type") = Me.[LOG_Log_Type]
rst("log description") = Me.[LOG_Log_Description]
rst("department") = Me.[LOG_Department]
rst("email sent") = Me.[LOG_Email_Sent]
rst("email sent date") = Me.[LOG_Email_Sent_Date]
rst.Update
rst.Close
Set rst = Nothing
Me.Check100 = True
Else
MsgBox strTest
End If
End Sub
I am not great at code - so this may be something obvious.
When I run the code, everything works, but the form disappears. I think it may have something to do with sending the values to the log table. To be clear the form disappears, but does not close and switching out of access and back into it then displays the form again.
Does my code need tweaking in some way to make it better. All suggestions gratefully receeived,
Many thanks Mark
Private Sub btn_send_message_DblClick(Cancel As Integer)
Dim strTest As String
strTest = TestForm()
If strTest = "" Then strTest = SendMail
If strTest = "" Then
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("log", dbOpenDynaset)
rst.AddNew
rst("log date") = Now()
rst("note") = Me.[LOG_Note]
rst("landlord log ref") = Me.[LOG_landlord_log_ref]
rst("property log ref") = Me.[LOG_property_log_ref]
rst("tenant log ref") = Me.[LOG_tenant_log_ref]
rst("landlord name") = Me.[LOG_landlord_name]
rst("property name") = Me.[LOG_property_name]
rst("tenant name") = Me.[LOG_tenant_name]
rst("contractor name") = Me.[LOG_contractor_name]
rst("Log Cheque Amount") = Me.[LOG_Log_Cheque_Amount]
rst("log type") = Me.[LOG_Log_Type]
rst("log description") = Me.[LOG_Log_Description]
rst("department") = Me.[LOG_Department]
rst("email sent") = Me.[LOG_Email_Sent]
rst("email sent date") = Me.[LOG_Email_Sent_Date]
rst.Update
rst.Close
Set rst = Nothing
Me.Check100 = True
Else
MsgBox strTest
End If
End Sub