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
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