Hello,
The database I use at work is needing help, but I'm not sure how to accomplish this task using VBA or other methods. We enter information onto an "Evaluation" form and then submit it, sending information to two tables, "tblCoaching" and "tblSurveyInfo".
What I'm trying to do is exclude certain employee types from having information send to tblSurveyInfo and only tblCoaching.
Here is what the code and form look like for submitting the form:
Code:
Private Sub SubmitForm()
Dim rst As New ADODB.Recordset
Dim rstSrvyInf As New ADODB.Recordset
Dim bookmark As Long 'not using this anymore it will not keep accurate with data submittion
Dim bookmark2 As Long
Dim Continue As Integer
On Error GoTo Err_DataError
Continue = MsgBox("Are you sure you want to continue?", vbYesNo, "Submit Form")
Select Case Continue
Case vbNo
Exit Sub
End Select
With rst 'this rst will go to tblCoaching
.Open "tblCoaching", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
.AddNew
!EvaluatorID = Me("textEvaluatorID").Value
!EmployeeID = Me("textEmployeeID").Value
!CallTypeID = Me("comboCallType").Value
!DateofCall = Me("DateofCall").Value
!DateGraded = Me("DateGraded").Value
!NumberofCall = Me("NumberofCall").Value
!CallID = Me("CallID").Value
!TotalScore = Me("TotalScore").Value
!CustomerID = Me("CustomerID").Value
!CallLength = Me("textCallLength").Value
!OutCallID = Me("OutCallID").Value
!OutCustomerID = Me("OutCustomerID").Value
' Any additional fields to be updated go here.
.Update
bookmark2 = !CoachingID
End With
rst.Close
'MsgBox "The magic ID is " & rst!CoachingID
If Me("comboCallType").Value = "2" Or Me("comboCallType").Value = "10" Or Me("comboCallType").Value = "6" Or Me("comboCallType").Value = "7"_
Or Me("comboCallType").Value = "4" Or Me("comboCallType").Value = "69" Or Me("comboCallType").Value = "8" Or Me.textAssociateType.Value =_
"Customer Service" Then
With rstSrvyInf
.Open "tblSurveyInfo", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
.AddNew
!EvalID = Me("textEvalID").Value
!EmpID = Me("textEmpID").Value
!EmpNumber = Me("textEmpNumber").Value
!Supervisor = Me("textSupervisor").Value
!DateofCall = Me("textDateofCallS").Value
!SurveyID = Me("textSurveyID").Value
!CallType = Me("textCallType").Value
!CustomerID = Me("CustomerIDS").Value
!CustName = Me("textCustName").Value
!DateGraded = Me("DateGraded").Value
.Update
End With
rstSrvyInf.Close
Else
End If
When an employee name is entered into the textEmployeeName combobox on the form, it is coded to bring up their information including position type in text boxes. I'm trying to use that position type that is generated by their name to determine whether or not the rstSrvyInf is processed. The text box that includes the employee position is named textAssociateType.
I attempted to use an If Then statement like I did for certain "comboCallTypes" (which works), but it's not working for some reason.
Is there something I'm missing or an easy way to accomplish this? Please let me know if this requires more information to share on my part!
Thanks!