I just noticed that you had used Recordset.Clone in your code, and I copied
it without noticing. This is a better approach, using RecordsetClone:
Private Sub Item_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.RecordsetClone
rs.FindFirst "[Item_ID] = " & Str(Nz(Me![Item], 0))
If Not rs.NoMatch Then Me.Bookmark = rs.Bookmark
Set rs = Nothing
End Sub
If you want to use the combo box for navigation, then it needs to be in the
Header section of the form (subform), not the Detail section. And it should
not be bound to any field.
In a subsequent post, you mentioned the following:
"
Next I have made the control Source for the fsubGroup Subform into a query,
qrtQuery1:
SELECT tblItem.idsItem_ID, tblItem.chrItem, tblItem.hlkReference_Address,
tblItem.idrCompany_ID FROM tblItem;
The Control Source for cboItem on fsubGroup is chrItem, and the Row Source
is qryQuery1, Bound To Column 1.
The fsubGroup Click Event code now contains the code you gave me:
"
A subform control does not have a control source; it has a SourceObject
property. The form that is the SourceObject has a RecordSource property. I
assume that this latter term is what you meant?
I think that you can solve your problem if you put the combo box in the
header section and leave it unbound (its control source should be empty).
--
Ken Snell
<MS ACCESS MVP>
Dave Birley said:
«Or do you want to use the combo box as a "navigation" device to move the
subform to a desired record?»
That's the plan.
I tried inserting your code both in the After_Update of the subform and of
the Item combobox, with a Stop immediately before the rs.MoMatch line so
that
I could check what I was getting in that Item value -- surprise (to me
anyway) when I click on a row below the top one the code doesn't stop.
Hmmmmm. At least I know now what I am NOT doing right <g>.
Needless to say -- help still needed! (had a lovely time reading a novel
Friday <g>)
--
Dave
Temping with Staffmark
in Rock Hill, SC
Ken Snell (MVP) said:
I'm not completely sure I understand what you're seeing, but if you're
running the code (which is slightly erroneous if you want to move only if
a
record is found) you show in the AfterUpdate event of the combo box, then
the subform will "move" to the first record that matches the value found
in
the current record's Item field control (is that the name of the
combobox?).
Do you want the combo box to be used just for selecting a value for the
Item_ID field in the current record? Or do you want to use the combo box
as
a "navigation" device to move the subform to a desired record?
FYI -- Corrected code to move to a record (note use of NoMatch property,
not
EOF property):
Private Sub Item_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Item_ID] = " & Str(Nz(Me![Item], 0))
If Not rs.NoMatch Then Me.Bookmark = rs.Bookmark
End Sub
--
Ken Snell
<MS ACCESS MVP>
«Is the combo box bound to a field?»
Yes. Field 1, which is Item_ID. When I bind it to field 4 which is
Item,
the
text field containing the Item Names, the Combobox comes up empty. Only
binding it to field 1 results in it being populated.
«Is the combo box locked?»
No
«Where in the subform is the combo box located -- form header? form
detail?
somewhere else?»
Form Detail
I thought overnight that perhaps what was needed was an After Update
for
this li'l pup, so I added this to the Combobox:
Private Sub Item_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Item_ID] = " & Str(Nz(Me![Item], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
.. but it didn't help.
--
Dave
Temping with Staffmark
in Rock Hill, SC
:
You're saying that the combobox moves to the first value in the
dropdown
list whenever you select a value in the dropdown list? Is the combo
box
bound to a field? Is the combo box locked? Where in the subform is the
combo
box located -- form header? form detail? somewhere else?
--
Ken Snell
<MS ACCESS MVP>
This appears to be my final frontier on the current project. All
other
threads relating to it are now closed.
My data which displays in the Items Combobox of the Group Subform
is,
finally, the right data. The problem is that when I click on an item
in
the
expanded combobox the pointer immediately jumps back tot he first
displayed
record.
The Combobox has the controlling table of the subform as its control
source,
and displays a single field from that table. I have checked and
there
are
no
dangling Events that could be causing this.
Anyone got any ideas where I should be looking to stop this?