Good morning forums,
I have yet another question that has been giving me issues lately. I am probably just going about all wrong. I am working on a replace function to replace %reasonforvisit% with the actual field value and so far the code runs without error however; the data is not passed and now the main menu wont open after the form closes. Is there also a way to get this code to automatically send rather than display the email? Ive tried setting .display to .send but i never get the email. My replace function looks like this and bear with me you'll probably find a million mistakes..,
I have yet another question that has been giving me issues lately. I am probably just going about all wrong. I am working on a replace function to replace %reasonforvisit% with the actual field value and so far the code runs without error however; the data is not passed and now the main menu wont open after the form closes. Is there also a way to get this code to automatically send rather than display the email? Ive tried setting .display to .send but i never get the email. My replace function looks like this and bear with me you'll probably find a million mistakes..,
Code:
Private Sub Command38_Click()
Dim intUSL As Integer
Dim olApp As Object
Dim objMail As Object
Dim strRFV As String
strRFV = Me.Reason_or_Visit
'Set the record as completed and remove it from the Customer Queue.
Me.Status = "Completed"
Me.Date_Time_of_Completion = Now()
RunCommand acCmdSaveRecord
Forms![Customer_Queue]![Servicing].Form.RecordSource = "Servicing"
'Keep going if there is an error
On Error Resume Next
'See if Outlook is open
Set olApp = GetObject(, "Outlook.Application")
'Outlook is not open
If Err Then
'Create a new instance of Outlook
Set olApp = CreateObject("Outlook.Application")
End If
'Create e-mail item
Set objMail = olApp.CreateItemFromTemplate(Application.CurrentProject.Path + "\untitled.oft")
With objMail
objMail.bodyformat = olFormatHTML
objMail.HTMLBody = Replace(objMail.HTMLBody, "%reasonforvisit%", strRFV)
objMail.sentonbehalfofname = ""
.To = Me.Cust_Email
.Subject = ""
.Attachments.Add ""
objMail.send
End With
DoCmd.Close
'Tells the database Who is logged in and which permission level they have.
intUSL = DLookup("[Password Type]", "Tech Login Info", "[Technician]='" & Forms!frmUSL.txtUN & "'")
Forms!frmUSL.txtUSL = intUSL
'Opens the correct form based on what permissions the user has.
Select Case intUSL
Case 2
DoCmd.OpenForm "Main Menu", acNormal, , , acFormReadOnly
Case 1
DoCmd.OpenForm "Sup_Admin Form", acNormal
Case 3
MsgBox "Not configured yet", vbExclamation, "Not configured"
Case 4
MsgBox "Not configured yet", vbExclamation, "Not configured"
End Select
'Clean up
Set olApp = Nothing
Set objMail = Nothing
End Sub
Last edited: