Strange Behavior with Form Filter Fields

michee

Registered User.
Local time
Today, 08:27
Joined
Sep 11, 2014
Messages
16
I'm seeing some strange behavior with form filter fields that are set. I am trying to get the behavior to occur consistently but not always succeeding.

I have a form with two fields in the header meant for filtering the form data - SelectAtty and SelectClient. The query under the form is restricted based on the values selected. I also have a "button" that if clicked should filter the records (probably unnecessary but I thought it would be clearer for the user). I'm seeing two issues. Sometimes when I select a value - it doesn't appear to apply it to the query at all. When I add msgbox statements to try to see what is happening, the problem goes away (weird right). Also I run into a "no current record" error when it requeries. Mostly this seems to happen when I have two events that fire in a row and both requery.

I could use some help - this really shouldn't be complex but I seem to be stuck.

The event procedures are below and you can see where I put my debugging msgbox statements.
1. No current record fires consistently on the filter image click and (I think) always when it requeries twice (like I changed the value and then clicked on the filter).
2. The fact that sometimes the selections are picked up in the query and sometimes aren't I have no good pattern for other than msgboxes seem to actually fix it - as if it forces access to look at the values and they they show up. Maybe I need a refresh or something??


Private Sub FilterImage_Click()
MsgBox "filter: " & Form.CurrentRecord
MsgBox Form.RecordSource
MsgBox "Select Attylike : " & (Nz([Forms]![F_Maintain_Client_Record]![SelectAttyMaint], "*")) & " select client like:" & "*" & [Forms]![F_Maintain_Client_Record]![SelectClientMaint] & "*"
Form.Requery
End Sub


Private Sub Form_Load()
MsgBox "formload"
Me.SelectAttyMaint = Null
Me.SelectClientMaint = Null
End Sub

Private Sub SelectAttyMaint_Change()
MsgBox "selectatty: " & Form.CurrentRecord
MsgBox Form.RecordSource
MsgBox "Select Attylike : " & (Nz([Forms]![F_Maintain_Client_Record]![SelectAttyMaint], "*")) & " select client like:" & "*" & [Forms]![F_Maintain_Client_Record]![SelectClientMaint] & "*"
Form.Requery
End Sub

Private Sub SelectClientMaint_Exit(Cancel As Integer)
MsgBox "Select Client: " & Form.CurrentRecord
MsgBox Form.RecordSource
MsgBox "Select Attylike : " & (Nz([Forms]![F_Maintain_Client_Record]![SelectAttyMaint], "*")) & " select client like:" & "*" & [Forms]![F_Maintain_Client_Record]![SelectClientMaint] & "*"
Form.Requery
End Sub
 
Continued testing - still stuck
1. I officially retract my "the msgbox fixes it" statement as I tried again resetting - recompiling - closing out completely and going back into the form and it is doing it again. I choose "error" for the atty, the msgbox clearly shows me the correct value for the Atty Id and yet when it requeries the data is not filtered! aargh.

2. I got the query to recognize the filters by opening up the query - just looking at it, no changes, and closing it and then re running the form. However if I close all the way out of the form and re run it, it doesn't work again.:banghead:
 
Last edited:
I changed the form so that it used the filter property instead of parameterizing the query. It works. Still don't know why the other way didn't.
 

Users who are viewing this thread

Back
Top Bottom