Using combo box to control record source

G

Guest

I have a combo box that I'm trying to use to control which recourd source a
dependant subform is using to filter, in this case catagory.
My combo box after update code looks like this:
Private Sub Combo39_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Catagory Id] = " & Str(Nz(Me![Combo39], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

For some reason no matter which catagory I select my record never changes,
navagating catagories by the record selector at the bottom of the form works
fine, I just cant seem to get this combo box working :/
 
A

Armen Stein

I have a combo box that I'm trying to use to control which recourd source a
dependant subform is using to filter, in this case catagory.
My combo box after update code looks like this:
Private Sub Combo39_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Catagory Id] = " & Str(Nz(Me![Combo39], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

For some reason no matter which catagory I select my record never changes,
navagating catagories by the record selector at the bottom of the form works
fine, I just cant seem to get this combo box working :/

The Bookmark property is just a pointer to a particular record - not a
filter. Your code is basically saying "find a particular record on the
current form, then position to it." It doesn't do anything with a
subform.

Normally, subforms are filtered using the Master Fields and Child Fields
properties. Check to see if those are set correctly.

If you want to filter the subform even further than just the
Master/Child, you would need to add a Where clause to its Recordsource,
using the syntax Me.[subformcontrolname].Form.Recordsource.
 
G

Guest

Armen Stein said:
I have a combo box that I'm trying to use to control which recourd source a
dependant subform is using to filter, in this case catagory.
My combo box after update code looks like this:
Private Sub Combo39_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Catagory Id] = " & Str(Nz(Me![Combo39], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

For some reason no matter which catagory I select my record never changes,
navagating catagories by the record selector at the bottom of the form works
fine, I just cant seem to get this combo box working :/

The Bookmark property is just a pointer to a particular record - not a
filter. Your code is basically saying "find a particular record on the
current form, then position to it." It doesn't do anything with a
subform.

Normally, subforms are filtered using the Master Fields and Child Fields
properties. Check to see if those are set correctly.

If you want to filter the subform even further than just the
Master/Child, you would need to add a Where clause to its Recordsource,
using the syntax Me.[subformcontrolname].Form.Recordsource.
My master and child forms are alright, the subform is being filtered
correctly. What I'm trying to do is use a combo box to navigate the catagory
record that is doing the filtering instead of using the built in record
controls at the bottom of my form, that was i can select a particular
catagory without scrolling through the whole list
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top