Hi all,
This isn't life or death but it’s annoying me & this kind of thing usually indicates a bad design so...
I have a continuous form linked to a multi-table query. All query data are bound to controls in the detail section. All detail fields are disabled - this form just shows history, no updating. In the header section I have two unbound controls that I’m trying to feed to the form's Me.Filter (as per code below). Filter works dandy. However…
The annoying thing is that the last detail line shows "AutoNumber" it's a primary key field (DocID) of one tables of the query. If I disable the Me.AllowAdditions field the “AutoNumber” goes away but the unbound header controls will sometimes blank themselves. I.e. filter works just as expected, based upon the entered data in the header controls, but the controls set themselves to NULL (sometimes) after the filter.
This isn't life or death but it’s annoying me & this kind of thing usually indicates a bad design so...
I have a continuous form linked to a multi-table query. All query data are bound to controls in the detail section. All detail fields are disabled - this form just shows history, no updating. In the header section I have two unbound controls that I’m trying to feed to the form's Me.Filter (as per code below). Filter works dandy. However…
The annoying thing is that the last detail line shows "AutoNumber" it's a primary key field (DocID) of one tables of the query. If I disable the Me.AllowAdditions field the “AutoNumber” goes away but the unbound header controls will sometimes blank themselves. I.e. filter works just as expected, based upon the entered data in the header controls, but the controls set themselves to NULL (sometimes) after the filter.
Code:
Option Compare Database
Option Explicit
Dim FilterStr As String
Private Sub Form_Load()
Me.SelPayee = ""
Me.SelType = ""
FilterStr = ""
Me.Filter = FilterStr
Me.FilterOn = True
End Sub
Private Sub SelPayee_AfterUpdate()
FilterStr = ""
If Nz(Me.SelPayee, 0) Then _
FilterStr = FilterStr & "PayeeID = " & Me.SelPayee
If Nz(Me.SelPayee, 0) And Nz(Me.SelType, "") <> "" Then _
FilterStr = FilterStr & " AND "
If Nz(Me.SelType, "") <> "" Then _
FilterStr = FilterStr & "Payments.Type = '" & Me.SelType & "'"
Me.Filter = FilterStr
Me.FilterOn = True
End Sub
Private Sub SelType_AfterUpdate()
FilterStr = ""
If Nz(Me.SelPayee, 0) Then _
FilterStr = FilterStr & "PayeeID = " & Me.SelPayee
If Nz(Me.SelPayee, 0) And Nz(Me.SelType, "") <> "" Then _
FilterStr = FilterStr & " AND "
If Nz(Me.SelType, "") <> "" Then _
FilterStr = FilterStr & "Payments.Type = '" & Me.SelType & "'"
Me.Filter = FilterStr
Me.FilterOn = True
End Sub