Let's see if this code comes through OK.
This is the "On Load" event procedure code for the entire form.
Option Compare Database
Option Explicit
Dim LocationToApply As String
Dim StatusToApply As String
Private Sub ApplyLocation_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If ApplyLocation Then
ApplyLocation = False
Else
ApplyLocation = True
End If
End Sub
Private Sub ApplyStatus_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If ApplyStatus Then
ApplyStatus = False
Else
ApplyStatus = True
End If
End Sub
Private Sub cmb_container_status_id_GotFocus()
If ApplyStatus Then
container_id_filter.SetFocus
End If
End Sub
Private Sub cmb_container_status_id_LostFocus()
container_id_filter.SetFocus
End Sub
Private Sub cmb_location_LostFocus()
If Not ApplyStatus Then
cmb_container_status_id.SetFocus
Else
container_id_filter.SetFocus
End If
End Sub
Private Sub container_id_filter_LostFocus()
If Not IsNull(container_id_filter.Value) Then
If Not IsNull(cmb_location.Value) Then
LocationToApply = cmb_location.Value
End If
If Not IsNull(cmb_container_status_id.Value) Then
StatusToApply = cmb_container_status_id.Value
End If
Form.RecordSource = "select * from tbl_containers where container_id = " & containier_id_filter.Value
If ApplyLocation Then
cmb_location.Value = LocationToApply
End If
If ApplyStatus Then
cmb_container_status_id.Value = StatusToApply
End If
Else
Form.RecordSource = "select top 1 * from tbl_containers where container_id is not null"
End If
' On Error Resume Next
' If Not ApplyLocation Then
' cmb_location.SetFocus
' Exit Sub
' End If
' If Not ApplyStatus Then
' cmb_container_status_id.SetFocus
' Exit Sub
' End If
End Sub
Private Sub cmb_location_GotFocus()
If ApplyLocation Then
container_id_filter.SetFocus
End If
End Sub
Private Sub Form_Load()
Form.RecordSource = "select top 1 * from tbl_containers where container_id is not null"
End Sub
And this is the code for the combo boxes with the check boxes:
Option Compare Database
Option Explicit
Dim LocationToApply As String
Dim StatusToApply As String
Private Sub ApplyLocation_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If ApplyLocation Then
ApplyLocation = False
Else
ApplyLocation = True
End If
End Sub
Private Sub ApplyStatus_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If ApplyStatus Then
ApplyStatus = False
Else
ApplyStatus = True
End If
End Sub
Private Sub cmb_container_status_id_GotFocus()
If ApplyStatus Then
container_id_filter.SetFocus
End If
End Sub
Private Sub cmb_container_status_id_LostFocus()
container_id_filter.SetFocus
End Sub
Private Sub cmb_location_LostFocus()
If Not ApplyStatus Then
cmb_container_status_id.SetFocus
Else
container_id_filter.SetFocus
End If
End Sub
Private Sub container_id_filter_LostFocus()
If Not IsNull(container_id_filter.Value) Then
If Not IsNull(cmb_location.Value) Then
LocationToApply = cmb_location.Value
End If
If Not IsNull(cmb_container_status_id.Value) Then
StatusToApply = cmb_container_status_id.Value
End If
Form.RecordSource = "select * from tbl_containers where container_id = " & containier_id_filter.Value
If ApplyLocation Then
cmb_location.Value = LocationToApply
End If
If ApplyStatus Then
cmb_container_status_id.Value = StatusToApply
End If
Else
Form.RecordSource = "select top 1 * from tbl_containers where container_id is not null"
End If
' On Error Resume Next
' If Not ApplyLocation Then
' cmb_location.SetFocus
' Exit Sub
' End If
' If Not ApplyStatus Then
' cmb_container_status_id.SetFocus
' Exit Sub
' End If
End Sub
Private Sub cmb_location_GotFocus()
If ApplyLocation Then
container_id_filter.SetFocus
End If
End Sub
Private Sub Form_Load()
Form.RecordSource = "select top 1 * from tbl_containers where container_id is not null"
End Sub