changing mainform record from subform

J

JohnE

Hello. I have a main form with a subform on it. The main form is the one to
the subform many. I have it that when the main form changes the subform also
changes. The table that feeds both of these is one table. Similar to an
Employee's table with a supervisor is also an employee but can also have many
subordinates from the same table.

Anyway, what I am looking to do is to have a button on the subform
(continuous) at the end of each record that when click will change the
mainform to the selected subform record. An example is if the mainform had
record 2 showing with record 20, 35, 46 showing in the subform, if I select
#35, the mainform no goes to that record.

Currently, the code I am attempting to use is the following;

Option Compare Database
Option Explicit

Dim recordnum As Long

Private Sub btnGoTo_Click()
recordnum = Forms![frmChangeRequestDetail].CurrentRecord
Forms![frmChangeRequestDetail].Requery
DoCmd.GoToRecord acDataForm, "frmChangeRequestDetail", acGoTo, recordnum

End Sub

What is occuring with this code is that nothing changes but the form(s) do
requery.

Can anyone assist on this?

Thanks... John
 
B

Beetle

Private Sub btnGoTo_Click()

Dim frm As Form

Set frm = Me.Parent

frm.SetFocus

With frm.RecordsetClone
.FindFirst "EmployeeID=" & Me!EmployeeID
If Not .NoMatch Then frm.Bookmark = .Bookmark
End With

End Sub

The above assumes your PK field is called EmployeeID. Adjust
as necessary.
 
J

JohnE

Perfect! Thanks Beetle.



Beetle said:
Private Sub btnGoTo_Click()

Dim frm As Form

Set frm = Me.Parent

frm.SetFocus

With frm.RecordsetClone
.FindFirst "EmployeeID=" & Me!EmployeeID
If Not .NoMatch Then frm.Bookmark = .Bookmark
End With

End Sub

The above assumes your PK field is called EmployeeID. Adjust
as necessary.

--
_________

Sean Bailey


JohnE said:
Hello. I have a main form with a subform on it. The main form is the one to
the subform many. I have it that when the main form changes the subform also
changes. The table that feeds both of these is one table. Similar to an
Employee's table with a supervisor is also an employee but can also have many
subordinates from the same table.

Anyway, what I am looking to do is to have a button on the subform
(continuous) at the end of each record that when click will change the
mainform to the selected subform record. An example is if the mainform had
record 2 showing with record 20, 35, 46 showing in the subform, if I select
#35, the mainform no goes to that record.

Currently, the code I am attempting to use is the following;

Option Compare Database
Option Explicit

Dim recordnum As Long

Private Sub btnGoTo_Click()
recordnum = Forms![frmChangeRequestDetail].CurrentRecord
Forms![frmChangeRequestDetail].Requery
DoCmd.GoToRecord acDataForm, "frmChangeRequestDetail", acGoTo, recordnum

End Sub

What is occuring with this code is that nothing changes but the form(s) do
requery.

Can anyone assist on this?

Thanks... John
 
G

gael

Beetle said:
Private Sub btnGoTo_Click()

Dim frm As Form

Set frm = Me.Parent

frm.SetFocus

With frm.RecordsetClone
.FindFirst "EmployeeID=" & Me!EmployeeID
If Not .NoMatch Then frm.Bookmark = .Bookmark
End With

End Sub

The above assumes your PK field is called EmployeeID. Adjust
as necessary.
je pas
oui

Sean Bailey


JohnE said:
Hello. I have a main form with a subform on it. The main form is the
one to
the subform many. I have it that when the main form changes the subform
also
changes. The table that feeds both of these is one table. Similar to an
Employee's table with a supervisor is also an employee but can also have
many
subordinates from the same table.

Anyway, what I am looking to do is to have a button on the subform
(continuous) at the end of each record that when click will change the
mainform to the selected subform record. An example is if the mainform
had
record 2 showing with record 20, 35, 46 showing in the subform, if I
select
#35, the mainform no goes to that record.

Currently, the code I am attempting to use is the following;

Option Compare Database
Option Explicit

Dim recordnum As Long

Private Sub btnGoTo_Click()
recordnum = Forms![frmChangeRequestDetail].CurrentRecord
Forms![frmChangeRequestDetail].Requery
DoCmd.GoToRecord acDataForm, "frmChangeRequestDetail", acGoTo,
recordnum

End Sub

What is occuring with this code is that nothing changes but the form(s)
do
requery.

Can anyone assist on this?

Thanks... John
 

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