Hi Guys,
Have a bit of a problem with a script I am trying to run. I am asking my script to run through a list in the current form but the script cannot recognize the form. the script looks as follows.
Form name is "Coaching and Training Logger"
Private Sub cmdSubmit_Click()
Dim EnteredError As String
Dim ErrorSummary As String
Dim MessageTitle As String
Dim oItem As Variant
Dim CallCentreAgentsTemp1 As String
Dim SubCategoryTemp1 As String
Me.Refresh
CallCentreAgentsTemp1 = ""
SubCategoryTemp1 = ""
EnteredError = 0
For Each oItem In Forms![Coaching and Training Logger]!lstAgents.ItemSelected
If iCount = 0 Then
CallCentreAgentsTemp1 = Forms![Coaching and Training Logger]!lstAgents.ItemData(oItem)
End If
iCount = iCount + 1
Next oItem
iCount = o
If Me.txtStartDate = "" Then
EnteredError = 1
ErrorSummary = ErrorSummary & " - Start Date" & vbCrLf
End If
If Me.txtEndDate = "" Then
EnteredError = 1
ErrorSummary = ErrorSummary & " - End Date" & vbCrLf
End If
If Me.cboEmployee = "" Then
EnteredError = 1
ErrorSummary = ErrorSummary & " - Coach/Trainer" & vbCrLf
End If
If Me.cboType = "" Then
EnteredError = 1
ErrorSummary = ErrorSummary & " - Type" & vbCrLf
End If
If Me.cboDepartment = "" Then
EnteredError = 1
ErrorSummary = ErrorSummary & " - Department" & vbCrLf
End If
If Me.cboCategory = "" Then
EnteredError = 1
ErrorSummary = ErrorSummary & " - Category" & vbCrLf
End If
If Me.lstAgents = "" Then
EnteredError = 1
ErrorSummary = ErrorSummary & " - Agents" & vbCrLf
End If
If Me.lstSubCategory = "" Then
EnteredError = 1
ErrorSummary = ErrorSummary & " - Sub-Category" & vbCrLf
End If
If EnteredError = 1 Then
ErrorSummary = "The Following Fields are Required: " & vbCrLf & vbCrLf & ErrorSummary
MessageTitle = "Action Required!"
MsgBox ErrorSummary, vbInformation, MessageTitle
End If
iCount = 0
If EnteredError <> 1 Then
'Add Data to Table
CurrentDb.Execute "INSERT INTO Logdata(Logtime,StartTime,EndTime,Employee,Type,Department,Category,MethodUsed,CallCentreAgent1)" & "VALUES('" & Now() & "','" & Me.txtStartDate.Value & "','" & Me.txtEndDate.Value & "','" & Me.cboEmployee.Value & "','" & Me.cboType.Value & "','" & Me.cboDepartment.Value & "','" & Me.cboCategory.Value & "','" & Me.cboMethodUsed.Value & "','" & CallCenterAgentTemp1 & "')"
'Clear form
cmdClear_Click
End If
End Sub
Any help would really be appreciated.
kind regards,
MG
Have a bit of a problem with a script I am trying to run. I am asking my script to run through a list in the current form but the script cannot recognize the form. the script looks as follows.
Form name is "Coaching and Training Logger"
Private Sub cmdSubmit_Click()
Dim EnteredError As String
Dim ErrorSummary As String
Dim MessageTitle As String
Dim oItem As Variant
Dim CallCentreAgentsTemp1 As String
Dim SubCategoryTemp1 As String
Me.Refresh
CallCentreAgentsTemp1 = ""
SubCategoryTemp1 = ""
EnteredError = 0
For Each oItem In Forms![Coaching and Training Logger]!lstAgents.ItemSelected
If iCount = 0 Then
CallCentreAgentsTemp1 = Forms![Coaching and Training Logger]!lstAgents.ItemData(oItem)
End If
iCount = iCount + 1
Next oItem
iCount = o
If Me.txtStartDate = "" Then
EnteredError = 1
ErrorSummary = ErrorSummary & " - Start Date" & vbCrLf
End If
If Me.txtEndDate = "" Then
EnteredError = 1
ErrorSummary = ErrorSummary & " - End Date" & vbCrLf
End If
If Me.cboEmployee = "" Then
EnteredError = 1
ErrorSummary = ErrorSummary & " - Coach/Trainer" & vbCrLf
End If
If Me.cboType = "" Then
EnteredError = 1
ErrorSummary = ErrorSummary & " - Type" & vbCrLf
End If
If Me.cboDepartment = "" Then
EnteredError = 1
ErrorSummary = ErrorSummary & " - Department" & vbCrLf
End If
If Me.cboCategory = "" Then
EnteredError = 1
ErrorSummary = ErrorSummary & " - Category" & vbCrLf
End If
If Me.lstAgents = "" Then
EnteredError = 1
ErrorSummary = ErrorSummary & " - Agents" & vbCrLf
End If
If Me.lstSubCategory = "" Then
EnteredError = 1
ErrorSummary = ErrorSummary & " - Sub-Category" & vbCrLf
End If
If EnteredError = 1 Then
ErrorSummary = "The Following Fields are Required: " & vbCrLf & vbCrLf & ErrorSummary
MessageTitle = "Action Required!"
MsgBox ErrorSummary, vbInformation, MessageTitle
End If
iCount = 0
If EnteredError <> 1 Then
'Add Data to Table
CurrentDb.Execute "INSERT INTO Logdata(Logtime,StartTime,EndTime,Employee,Type,Department,Category,MethodUsed,CallCentreAgent1)" & "VALUES('" & Now() & "','" & Me.txtStartDate.Value & "','" & Me.txtEndDate.Value & "','" & Me.cboEmployee.Value & "','" & Me.cboType.Value & "','" & Me.cboDepartment.Value & "','" & Me.cboCategory.Value & "','" & Me.cboMethodUsed.Value & "','" & CallCenterAgentTemp1 & "')"
'Clear form
cmdClear_Click
End If
End Sub
Any help would really be appreciated.
kind regards,
MG