Hi all,
I'm having difficulty to simplify my coding. It is on a command button which is making a new line in my table then go to this line on my form. This action take 7-8 seconds and I'm trying to reduce that as much as possible.
Here is the code:
Thank you
I'm having difficulty to simplify my coding. It is on a command button which is making a new line in my table then go to this line on my form. This action take 7-8 seconds and I'm trying to reduce that as much as possible.
Here is the code:
Code:
Private Sub cmdNewTicket_Click()
DoCmd.SetWarnings False
DoCmd.OpenQuery "New Call"
Form.Requery
If Me.Chk1 = 0 Then
Me.Chk1 = -1
End If
StatusChoice
DoCmd.GoToRecord , , acLast
Me.txtShpDate = Date
Me.txtFollowUp = Date + 1
If Me.txtOnHold = 0 Then
Me.txtOnHold.BackColor = 65280
Else
If Me.txtOnHold = 1 Then
Me.txtOnHold.BackColor = 65535
Else
If Me.txtOnHold = 2 Then
Me.txtOnHold.BackColor = 255
Else
Me.txtOnHold.BackColor = 255
End If
End If
End If
Me.txtSearch = ""
DoCmd.SetWarnings True
End Sub
Code:
Private Function StatusChoice()
Dim OpenCall As String
If Me!Chk1 = -1 Then
OpenCall = "[status] = '1'"
End If
If Me!Chk2 = -1 Then
If Len(OpenCall) <> 0 Then
OpenCall = OpenCall & " Or "
End If
OpenCall = OpenCall & "[status] = '2'"
End If
If Me!Chk7 = -1 Then
If Len(OpenCall) <> 0 Then
OpenCall = OpenCall & " Or "
End If
OpenCall = OpenCall & "[status] = '7'"
End If
If Me!chkClerkYesNo = -1 Then
If Len(OpenCall) <> 0 Then
OpenCall = OpenCall & ") And " & "[clerk] = " & Me.txtClerkID
Else
OpenCall = OpenCall & "[clerk] = " & Me.txtClerkID & ")"
End If
End If
If Len(OpenCall) <> 0 Then
If Me!chkClerkYesNo = -1 Then
OpenCall = "(" & OpenCall
End If
OpenCall = "(" & OpenCall & ")"
Else
OpenCall = ""
End If
If OpenCall = "" Then
DoCmd.ShowAllRecords
Else
DoCmd.ShowAllRecords
DoCmd.ApplyFilter , OpenCall
End If
If Me.RecordsetClone.RecordCount = 0 Then
Else
DoCmd.GoToRecord , , acLast
End If
End Function
Thank you