Stang70Fastback
Registered User.
- Local time
- Today, 17:26
- Joined
- Dec 24, 2012
- Messages
- 132
Hello folks. I'm sure this is another simple one, but I can't seem to find the solution anywhere.
I'm using VBA code to set a form's filter and sort order based on certain criteria (mostly, which user is logging into the database). For example:
This works fine. HOWEVER, these filter criteria "stick" in the form's filter and order properties in the right-hand pane. What this means is that if I switch from one user to another, such that the VBA code now wants to apply different filters and sorts, the form just shows up blank (as in a giant white box). I think it's because the last used filter and order criteria are sticking in the form properties, and are conflicting with the new filter and order criteria that my VBA code is trying to apply. If I clear out the filter and order stuff in the form properties, then the VBA code works fine again.
I tried adding Me.FilterOn = False, and Me.OrderByOn = False ahead of that chunk of code, thinking if I turned off the filters before resetting them, it should work but it doesn't help. How can I get the form to NOT remember filter settings the next time the ACCDE file is opened?
I'm using VBA code to set a form's filter and sort order based on certain criteria (mostly, which user is logging into the database). For example:
Code:
If DCount("[Username]", "USER", "[Username] = '" & fOSUserName & "' AND [Authority] = 'Normal'") = 1 Then
Me.Filter = "[CreatedName] = '" & fOSUserName & "'"
Me.FilterOn = True
Me.OrderBy = "[WeekEnding] DESC"
Me.OrderByOn = True
ElseIf DCount("[Username]", "USER", "[Username] = '" & fOSUserName & "' AND [Authority] = 'Admin'") = 1 Then
Me.Filter = "Not IsNull([SubmittedName]) OR [CreatedName] = '" & fOSUserName & "'"
Me.FilterOn = True
Me.OrderBy = "[ManagerName] IS NULL ASC, [WeekEnding] DESC, [LastName] ASC"
Me.OrderByOn = True
Else
Me.Filter = "Not IsNull([ManagerName]) OR [CreatedName] = '" & fOSUserName & "'"
Me.FilterOn = True
Me.OrderBy = "[TimekeeperName] IS NULL ASC, [WeekEnding] DESC, [LastName] ASC"
Me.OrderByOn = True
End If
This works fine. HOWEVER, these filter criteria "stick" in the form's filter and order properties in the right-hand pane. What this means is that if I switch from one user to another, such that the VBA code now wants to apply different filters and sorts, the form just shows up blank (as in a giant white box). I think it's because the last used filter and order criteria are sticking in the form properties, and are conflicting with the new filter and order criteria that my VBA code is trying to apply. If I clear out the filter and order stuff in the form properties, then the VBA code works fine again.
I tried adding Me.FilterOn = False, and Me.OrderByOn = False ahead of that chunk of code, thinking if I turned off the filters before resetting them, it should work but it doesn't help. How can I get the form to NOT remember filter settings the next time the ACCDE file is opened?
Last edited: