stay on same record

R

robertm600635

I have a main form with a subform control. I have several subforms that I
switch in the subform control using a combobox. I pull up a record from the
main form (main table=tblClients) using a combobox. The problem is when I
switch the subform in the subform control, the record on the main form always
goes back to first record in the table. Is there a way I can stay on the same
record I am viewing when the subform is switched?
 
O

Ofer Cohen

You might have in your code
Me.Requery

That will make the form move to the first record.
If that the case, is it necessary to run the requery?
 
R

robertm600635

There is no me.requery in my code.

Ofer Cohen said:
You might have in your code
Me.Requery

That will make the form move to the first record.
If that the case, is it necessary to run the requery?
 
K

Klatuu

There is something in your code that is causing that. It would be the normal
case for the main form's record to remain on the current record. Use Debug
mode to trace through your code and see when and why this is happening.
 
R

robertm600635

The only code that I can see maybe causing this is the name serch combobox.
Could this be some sort of sorting on the table level causing it?

Private Sub cboNameSearchRoster_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

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

Klatuu

The code you posted will cause the current record of the form to become
whatever is selected in the combo box.
--
Dave Hargis, Microsoft Access MVP


robertm600635 said:
The only code that I can see maybe causing this is the name serch combobox.
Could this be some sort of sorting on the table level causing it?

Private Sub cboNameSearchRoster_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

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

Klatuu said:
There is something in your code that is causing that. It would be the normal
case for the main form's record to remain on the current record. Use Debug
mode to trace through your code and see when and why this is happening.
 
R

robertm600635

Yes, that's what I use it for, but when I switch the subform it does not stay
The code you posted will cause the current record of the form to become
whatever is selected in the combo box.
--
Dave Hargis, Microsoft Access MVP


robertm600635 said:
The only code that I can see maybe causing this is the name serch combobox.
Could this be some sort of sorting on the table level causing it?

Private Sub cboNameSearchRoster_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

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

Klatuu said:
There is something in your code that is causing that. It would be the normal
case for the main form's record to remain on the current record. Use Debug
mode to trace through your code and see when and why this is happening.
--
Dave Hargis, Microsoft Access MVP


:

There is no me.requery in my code.

:

You might have in your code
Me.Requery

That will make the form move to the first record.
If that the case, is it necessary to run the requery?


--
Good Luck
BS"D


:

I have a main form with a subform control. I have several subforms that I
switch in the subform control using a combobox. I pull up a record from the
main form (main table=tblClients) using a combobox. The problem is when I
switch the subform in the subform control, the record on the main form always
goes back to first record in the table. Is there a way I can stay on the same
record I am viewing when the subform is switched?
 
K

Klatuu

How are the data for the form and subform related? What are the Link Master
fields and Link Child Fields set to in the subform control?
--
Dave Hargis, Microsoft Access MVP


robertm600635 said:
Yes, that's what I use it for, but when I switch the subform it does not stay
The code you posted will cause the current record of the form to become
whatever is selected in the combo box.
--
Dave Hargis, Microsoft Access MVP


robertm600635 said:
The only code that I can see maybe causing this is the name serch combobox.
Could this be some sort of sorting on the table level causing it?

Private Sub cboNameSearchRoster_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

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

:

There is something in your code that is causing that. It would be the normal
case for the main form's record to remain on the current record. Use Debug
mode to trace through your code and see when and why this is happening.
--
Dave Hargis, Microsoft Access MVP


:

There is no me.requery in my code.

:

You might have in your code
Me.Requery

That will make the form move to the first record.
If that the case, is it necessary to run the requery?


--
Good Luck
BS"D


:

I have a main form with a subform control. I have several subforms that I
switch in the subform control using a combobox. I pull up a record from the
main form (main table=tblClients) using a combobox. The problem is when I
switch the subform in the subform control, the record on the main form always
goes back to first record in the table. Is there a way I can stay on the same
record I am viewing when the subform is switched?
 
R

robertm600635

they are linked with the ClientID field which is the PK in the main table and
the FK in the child tables (one to many)

Klatuu said:
How are the data for the form and subform related? What are the Link Master
fields and Link Child Fields set to in the subform control?
--
Dave Hargis, Microsoft Access MVP


robertm600635 said:
Yes, that's what I use it for, but when I switch the subform it does not stay
The code you posted will cause the current record of the form to become
whatever is selected in the combo box.
--
Dave Hargis, Microsoft Access MVP


:

The only code that I can see maybe causing this is the name serch combobox.
Could this be some sort of sorting on the table level causing it?

Private Sub cboNameSearchRoster_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

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

:

There is something in your code that is causing that. It would be the normal
case for the main form's record to remain on the current record. Use Debug
mode to trace through your code and see when and why this is happening.
--
Dave Hargis, Microsoft Access MVP


:

There is no me.requery in my code.

:

You might have in your code
Me.Requery

That will make the form move to the first record.
If that the case, is it necessary to run the requery?


--
Good Luck
BS"D


:

I have a main form with a subform control. I have several subforms that I
switch in the subform control using a combobox. I pull up a record from the
main form (main table=tblClients) using a combobox. The problem is when I
switch the subform in the subform control, the record on the main form always
goes back to first record in the table. Is there a way I can stay on the same
record I am viewing when the subform is switched?
 
K

Klatuu

I think I have run out of ideas. It appears you have it done correctly. I
am back to my original statement that something you don't see is causing this
problem.
--
Dave Hargis, Microsoft Access MVP


robertm600635 said:
they are linked with the ClientID field which is the PK in the main table and
the FK in the child tables (one to many)

Klatuu said:
How are the data for the form and subform related? What are the Link Master
fields and Link Child Fields set to in the subform control?
--
Dave Hargis, Microsoft Access MVP


robertm600635 said:
Yes, that's what I use it for, but when I switch the subform it does not stay
on the record that is displayed in the combobox. It goes to the first record
in the main table. I want it to stay on the record in the combobox.

:

The code you posted will cause the current record of the form to become
whatever is selected in the combo box.
--
Dave Hargis, Microsoft Access MVP


:

The only code that I can see maybe causing this is the name serch combobox.
Could this be some sort of sorting on the table level causing it?

Private Sub cboNameSearchRoster_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

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

:

There is something in your code that is causing that. It would be the normal
case for the main form's record to remain on the current record. Use Debug
mode to trace through your code and see when and why this is happening.
--
Dave Hargis, Microsoft Access MVP


:

There is no me.requery in my code.

:

You might have in your code
Me.Requery

That will make the form move to the first record.
If that the case, is it necessary to run the requery?


--
Good Luck
BS"D


:

I have a main form with a subform control. I have several subforms that I
switch in the subform control using a combobox. I pull up a record from the
main form (main table=tblClients) using a combobox. The problem is when I
switch the subform in the subform control, the record on the main form always
goes back to first record in the table. Is there a way I can stay on the same
record I am viewing when the subform is switched?
 

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