Subform index

G

Gus Chuch

I have a form with a subform on it and it’s link to a combo box for
locations, when I pick a new location name from my combo box the subform
index pointer stays in the last place it was at. I would like to set the
index on the subform to go to the first record when a new name is picked. I
got the tab order OK I just would like to some how set the index to the first
record after update on the combo box.
Any ideas
 
S

Stuart McCall

Gus Chuch said:
I have a form with a subform on it and it's link to a combo box for
locations, when I pick a new location name from my combo box the subform
index pointer stays in the last place it was at. I would like to set the
index on the subform to go to the first record when a new name is picked.
I
got the tab order OK I just would like to some how set the index to the
first
record after update on the combo box.
Any ideas

With Me.ComboName
.Value = .ItemData(0)
End With
 
G

Gus Chuch

That’s not really what I’m looking for. That set’s the combo box index to 0.
I’m after the subform index to be set to 0.
 
J

John W. Vinson

That’s not really what I’m looking for. That set’s the combo box index to 0.
I’m after the subform index to be set to 0.

Subforms don't have an "Index" property. If you want the subform to display
the first record, use some appropriate event to execute code like:

Private Sub eventname()
DoCmd.GoToRecord,,acFirst
End Sub

John W. Vinson [MVP]
 
J

John W. Vinson

do I have to use an objectname for the subform? if so how would i do it?

GoToRecord defaults to the current form. I haven't tried it recently but I
think it should work - if not post back.

John W. Vinson [MVP]
 
G

Gus Chuch

I used the DoCmd.GoToRecord,,acFirst with no luck. I also used the wizard
with a command button but had no luck either. I’m looking in my VBA handbook
and if you omit the objecttype and objectname argument the active object is
assumed. The form would be the active object not the subform, right??
 
G

Gus Chuch

F.Y.I
I put the DoCmd.GoToRecord,,acFirst in the Form Activate Event
Private Sub Form_Activate()
DoCmd.GoToRecord , , acFirst
End Sub
works great
 

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