Hi Guys
I have a form named 'FrmMain' and on the Add Button, the following code is written. Basically it will open up the 'Input form' and ask users to enter the password before the email gets sent to the Agent . And after this I want to export a template in the shared folder( For this ExportForm sub is called and it is written in the same form 'FrmMain') but unfortunately ExportForm code doesn't run and I don't want to paste ExportForm Sub code in the 'Input form' or in a module. This is because this is the pre written code to code the template in all the forms in my database. And I just need to add the functionality to enter password by the Supervisor before the email gets sent to the Agent.
gPassKey,gAgent and gAgentName are global variable declared in a module. ExportForm sub is never called . Any help will be much appreciated.
Code:
Private Sub cmdAdd_Click()
Dim rst As Recordset
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Dim sEmailCC As String
Dim a As Boolean
Dim Supref As Integer
Dim FormRef As Integer
FormRef = 24
Me.txtHidden.SetFocus
gRef = Me.txtAuditID
gAgentName = cboAgent.Column(1)
gAgent = Me.cboAgent
If MsgBox("Do you wish to send this form to " & cboAgent.Column(1) & " to sign off?", vbQuestion + vbYesNo, "Send to Agent?") = vbYes Then
DoCmd.OpenForm "frm_InputMask"
Else
gPassKey = False
End If
If gPassKey = True Then
Call ExportForm
End If
Exit Sub
The following code is written in 'Input Form':
Code:
Option Compare Database
Private Sub cmdCancel_Click()
If MsgBox("Are you sure you want to close the form without entering the Password?" & vbCr & vbCr & "If you choose to cancel then the Agent won't be notified that the form is ready to signoff.", vbInformation + vbYesNo, "Cancel ?") = vbYes Then
DoCmd.Close acForm, Me.Name
gPassKey = False
Else
Me.txtInput = ""
gPassKey = False
End If
End Sub
Private Sub cmdOK_Click()
If StrComp(txtInput, DLookup("Passkey", "tbl_RMS_PassKey", "userID='" & NameofUser() & "'"), vbBinaryCompare) = 0 Then
gPassKey = True
Call Func_PassKey
DoCmd.Close acForm, Me.Name
Else
MsgBox "Incorrect password.Please try again." & vbCr & vbCr & "If you don't remember the password then go to Create/Recover PassKey form on the home page and you will be able to get the password from there.", vbCritical + vbOKOnly
Me.txtInput = ""
Me.txtInput.SetFocus
gPassKey = False
End If
End Sub