HillTJ
To train a dog, first know more than the dog..
- Local time
- Yesterday, 21:48
- Joined
- Apr 1, 2019
- Messages
- 731
Hi, I have a form with a series of unbound combo boxes to build a search string in the form header. I also have an unbound combo box 'Username' in the same header. It gets populated with the Username when the form loads. All good.
Problem is when I go to clear the filters with the routine below, I get error message 2448, which I believe is due to the routine unintentionally trying to save a "Null" in Unbound Combo Box 'Username'. I notice this as 'Username' loses it's value upon application of the clear filter button. The code I use is reproduced below. How can I Protect 'Username"' from being overwritten upon clearing of the filters? Appreciate any assistance.
Problem is when I go to clear the filters with the routine below, I get error message 2448, which I believe is due to the routine unintentionally trying to save a "Null" in Unbound Combo Box 'Username'. I notice this as 'Username' loses it's value upon application of the clear filter button. The code I use is reproduced below. How can I Protect 'Username"' from being overwritten upon clearing of the filters? Appreciate any assistance.
Code:
Private Sub Command26_Click()
'Purpose: Clear all the search boxes in the Form Header, and show all records again.
Dim ctl As Control
On Error GoTo ErrorHandler
'Clear all the controls in the Form Header section.
For Each ctl In Me.Section(acHeader).Controls
Select Case ctl.ControlType
Case acTextBox, acComboBox
ctl.Value = Null
Case acCheckBox
ctl.Value = False
End Select
Next
'Remove the form's filter.
Me.FilterOn = False
ExitError:
Exit Sub
ErrorHandler:
Select Case Err.Number
Case 9999
Resume Next
Case 999
Resume Next
Case Else
Call LogError(Err.Number, Err.Description, "Filter Off Selection")
Resume ExitError
End Select
End Sub