Hello Everyone,
I am new at using VBA but I am trying to filter a subform based on the selected value of another subform. Currently, I have it in a button "btnTestFilterPersonell" but I am noticing 2 things in particular.
Private Sub btnTestFilterPersonell_Click()
Set db = CurrentDb
Set rs = db.OpenRecordset("qryfrmLinkBuildingPersonell")
Dim SelectedValue As Long
SelectedValue = Form_frmLink.subfrmPersonellLink.Form!ID.Value
Me.Filter = "[tblPersonell.ID]=" & SelectedValue
Me.FilterOn = True
Debug.Print Me.FilterOn
Me.Requery
Debug.Print rs.Fields("tblPersonell.ID")
Debug.Print SelectedValue
Debug.Print SelectedValue&; "=" & rs.Fields(3)
Debug.Print Me.Filter
Set rs = Nothing
End Sub
1) The "Me.FilterOn" status does not change to true. It stays false even after I change the FilterOn status.
2) The Filter "[tblPersonell.ID]=" & SelectedValue is not being applied.
Below are the results that I am getting from the debug.print window
Debug.Print Me.FilterOn--False
Debug.Print rs.Fields("tblPersonell.ID")--135
Debug.Print SelectedValue--93
Debug.Print SelectedValue&; "=" & rs.Fields(3)--93 =135 (Column 3 is tblPersonell.ID)
Debug.Print Me.Filter--[tblPersonell.ID]=93
I am sure it is a simple fix but I am completely stumped and will gladly accept any help you offer.
Thanks,
I am new at using VBA but I am trying to filter a subform based on the selected value of another subform. Currently, I have it in a button "btnTestFilterPersonell" but I am noticing 2 things in particular.
Private Sub btnTestFilterPersonell_Click()
Set db = CurrentDb
Set rs = db.OpenRecordset("qryfrmLinkBuildingPersonell")
Dim SelectedValue As Long
SelectedValue = Form_frmLink.subfrmPersonellLink.Form!ID.Value
Me.Filter = "[tblPersonell.ID]=" & SelectedValue
Me.FilterOn = True
Debug.Print Me.FilterOn
Me.Requery
Debug.Print rs.Fields("tblPersonell.ID")
Debug.Print SelectedValue
Debug.Print SelectedValue&; "=" & rs.Fields(3)
Debug.Print Me.Filter
Set rs = Nothing
End Sub
1) The "Me.FilterOn" status does not change to true. It stays false even after I change the FilterOn status.
2) The Filter "[tblPersonell.ID]=" & SelectedValue is not being applied.
Below are the results that I am getting from the debug.print window
Debug.Print Me.FilterOn--False
Debug.Print rs.Fields("tblPersonell.ID")--135
Debug.Print SelectedValue--93
Debug.Print SelectedValue&; "=" & rs.Fields(3)--93 =135 (Column 3 is tblPersonell.ID)
Debug.Print Me.Filter--[tblPersonell.ID]=93
I am sure it is a simple fix but I am completely stumped and will gladly accept any help you offer.
Thanks,