Go to last record in a subform

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have many Main Forms, each has a subform for data entry. When I switch to a
main form I want cursor to go to last record on that subform. The go to
command does not work for me. Can someone help me with the code.
Thanks,
Floyd
 
Floyd,

Try using the form's Activate event procedure. You'll first need to set
focus to the subform control, and then go to the last record.

Me.[MySubformControl].SetFocus
DoCmd.GoToRecord , , acLast

Brian
 
Brian,
I'm very new to all this. What do I replace [MySubformControl] with. Also,
do I use the Main Form Activate event procedure to place the code.
Floyd

Brian Bastl said:
Floyd,

Try using the form's Activate event procedure. You'll first need to set
focus to the subform control, and then go to the last record.

Me.[MySubformControl].SetFocus
DoCmd.GoToRecord , , acLast

Brian


Floyd said:
I have many Main Forms, each has a subform for data entry. When I switch to a
main form I want cursor to go to last record on that subform. The go to
command does not work for me. Can someone help me with the code.
Thanks,
Floyd
 
Floyd,

Yes, it would go into the main form's coding module. You'd replace
[MySubformControl] with the name of the subform control on the main form.
Depending on how you set up your form, the subform control may or may not
have the same name as the subform. To check the name of the control, click
once in the very upper left-hand corner of the control, and then go to the
menu bar and click View | Properties. This will bring up the property sheet.
Across the Title bar of the property sheet, it should read:
Subform/Subreport: 'the name you want'.

It also works by simply typing Me. in the VBA editor. The period following
the Me will activate the Intellisense feature. You'd just scroll down the
list until you find a word which resembles what you think is the name of
your subform.

HTH,
Brian


Floyd said:
Brian,
I'm very new to all this. What do I replace [MySubformControl] with. Also,
do I use the Main Form Activate event procedure to place the code.
Floyd

Brian Bastl said:
Floyd,

Try using the form's Activate event procedure. You'll first need to set
focus to the subform control, and then go to the last record.

Me.[MySubformControl].SetFocus
DoCmd.GoToRecord , , acLast

Brian


Floyd said:
I have many Main Forms, each has a subform for data entry. When I
switch
to a
main form I want cursor to go to last record on that subform. The go to
command does not work for me. Can someone help me with the code.
Thanks,
Floyd
 
Brian,
I used your first suggestion by putting the Me statement in the main forms
Acitvate event procedure. When I open my first main form the cursor goes to
last record which is just what I want. However, when I select the next main
form with my record selector the focus goes to top of page which is the first
record of a long list. I have about 15 different main forms for each customer
and each has its own subform for order details.
Don't know how to us your last suggestion of putting Me. in VBA editor.

Floyd

Brian Bastl said:
Floyd,

Yes, it would go into the main form's coding module. You'd replace
[MySubformControl] with the name of the subform control on the main form.
Depending on how you set up your form, the subform control may or may not
have the same name as the subform. To check the name of the control, click
once in the very upper left-hand corner of the control, and then go to the
menu bar and click View | Properties. This will bring up the property sheet.
Across the Title bar of the property sheet, it should read:
Subform/Subreport: 'the name you want'.

It also works by simply typing Me. in the VBA editor. The period following
the Me will activate the Intellisense feature. You'd just scroll down the
list until you find a word which resembles what you think is the name of
your subform.

HTH,
Brian


Floyd said:
Brian,
I'm very new to all this. What do I replace [MySubformControl] with. Also,
do I use the Main Form Activate event procedure to place the code.
Floyd

Brian Bastl said:
Floyd,

Try using the form's Activate event procedure. You'll first need to set
focus to the subform control, and then go to the last record.

Me.[MySubformControl].SetFocus
DoCmd.GoToRecord , , acLast

Brian


I have many Main Forms, each has a subform for data entry. When I switch
to a
main form I want cursor to go to last record on that subform. The go to
command does not work for me. Can someone help me with the code.
Thanks,
Floyd
 
Floyd,

I must have misunderstood your intent. I read it that you wanted this
behavior when you open the form. Instead, I believe you are saying that you
want this to occur whenever you change records. In that case, you'll need to
use the form's On Current event procedure instead. But you'll only want this
behavior to occur if you are NOT on a new record on the main form. Otherwise
you run the risk of entering orphaned records in the subform. So you'll test
for a new record on the main form, and if it isn't, then the focus moves to
the subform control.

Private Sub Form_Current()
If Not Me.NewRecord Then
Me.[MySubformControl].SetFocus
DoCmd.GoToRecord , , acLast
End If
End Sub


HTH,
Brian


Floyd said:
Brian,
I used your first suggestion by putting the Me statement in the main forms
Acitvate event procedure. When I open my first main form the cursor goes to
last record which is just what I want. However, when I select the next main
form with my record selector the focus goes to top of page which is the first
record of a long list. I have about 15 different main forms for each customer
and each has its own subform for order details.
Don't know how to us your last suggestion of putting Me. in VBA editor.

Floyd

Brian Bastl said:
Floyd,

Yes, it would go into the main form's coding module. You'd replace
[MySubformControl] with the name of the subform control on the main form.
Depending on how you set up your form, the subform control may or may not
have the same name as the subform. To check the name of the control, click
once in the very upper left-hand corner of the control, and then go to the
menu bar and click View | Properties. This will bring up the property sheet.
Across the Title bar of the property sheet, it should read:
Subform/Subreport: 'the name you want'.

It also works by simply typing Me. in the VBA editor. The period following
the Me will activate the Intellisense feature. You'd just scroll down the
list until you find a word which resembles what you think is the name of
your subform.

HTH,
Brian


Floyd said:
Brian,
I'm very new to all this. What do I replace [MySubformControl] with. Also,
do I use the Main Form Activate event procedure to place the code.
Floyd

:

Floyd,

Try using the form's Activate event procedure. You'll first need to set
focus to the subform control, and then go to the last record.

Me.[MySubformControl].SetFocus
DoCmd.GoToRecord , , acLast

Brian


I have many Main Forms, each has a subform for data entry. When I switch
to a
main form I want cursor to go to last record on that subform. The
go
to
command does not work for me. Can someone help me with the code.
Thanks,
Floyd
 
Brian,
Your last suggestion worked well. I appreciate your help very much.
Thanks again and best wishes.
Floyd

Brian Bastl said:
Floyd,

I must have misunderstood your intent. I read it that you wanted this
behavior when you open the form. Instead, I believe you are saying that you
want this to occur whenever you change records. In that case, you'll need to
use the form's On Current event procedure instead. But you'll only want this
behavior to occur if you are NOT on a new record on the main form. Otherwise
you run the risk of entering orphaned records in the subform. So you'll test
for a new record on the main form, and if it isn't, then the focus moves to
the subform control.

Private Sub Form_Current()
If Not Me.NewRecord Then
Me.[MySubformControl].SetFocus
DoCmd.GoToRecord , , acLast
End If
End Sub


HTH,
Brian


Floyd said:
Brian,
I used your first suggestion by putting the Me statement in the main forms
Acitvate event procedure. When I open my first main form the cursor goes to
last record which is just what I want. However, when I select the next main
form with my record selector the focus goes to top of page which is the first
record of a long list. I have about 15 different main forms for each customer
and each has its own subform for order details.
Don't know how to us your last suggestion of putting Me. in VBA editor.

Floyd

Brian Bastl said:
Floyd,

Yes, it would go into the main form's coding module. You'd replace
[MySubformControl] with the name of the subform control on the main form.
Depending on how you set up your form, the subform control may or may not
have the same name as the subform. To check the name of the control, click
once in the very upper left-hand corner of the control, and then go to the
menu bar and click View | Properties. This will bring up the property sheet.
Across the Title bar of the property sheet, it should read:
Subform/Subreport: 'the name you want'.

It also works by simply typing Me. in the VBA editor. The period following
the Me will activate the Intellisense feature. You'd just scroll down the
list until you find a word which resembles what you think is the name of
your subform.

HTH,
Brian


Brian,
I'm very new to all this. What do I replace [MySubformControl] with. Also,
do I use the Main Form Activate event procedure to place the code.
Floyd

:

Floyd,

Try using the form's Activate event procedure. You'll first need to set
focus to the subform control, and then go to the last record.

Me.[MySubformControl].SetFocus
DoCmd.GoToRecord , , acLast

Brian


I have many Main Forms, each has a subform for data entry. When I
switch
to a
main form I want cursor to go to last record on that subform. The go
to
command does not work for me. Can someone help me with the code.
Thanks,
Floyd
 
You're welcome. Glad to help.

Brian


Floyd said:
Brian,
Your last suggestion worked well. I appreciate your help very much.
Thanks again and best wishes.
Floyd

Brian Bastl said:
Floyd,

I must have misunderstood your intent. I read it that you wanted this
behavior when you open the form. Instead, I believe you are saying that you
want this to occur whenever you change records. In that case, you'll need to
use the form's On Current event procedure instead. But you'll only want this
behavior to occur if you are NOT on a new record on the main form. Otherwise
you run the risk of entering orphaned records in the subform. So you'll test
for a new record on the main form, and if it isn't, then the focus moves to
the subform control.

Private Sub Form_Current()
If Not Me.NewRecord Then
Me.[MySubformControl].SetFocus
DoCmd.GoToRecord , , acLast
End If
End Sub


HTH,
Brian


Floyd said:
Brian,
I used your first suggestion by putting the Me statement in the main forms
Acitvate event procedure. When I open my first main form the cursor
goes
to
last record which is just what I want. However, when I select the next main
form with my record selector the focus goes to top of page which is
the
first
record of a long list. I have about 15 different main forms for each customer
and each has its own subform for order details.
Don't know how to us your last suggestion of putting Me. in VBA editor.

Floyd

:

Floyd,

Yes, it would go into the main form's coding module. You'd replace
[MySubformControl] with the name of the subform control on the main form.
Depending on how you set up your form, the subform control may or
may
not
have the same name as the subform. To check the name of the control, click
once in the very upper left-hand corner of the control, and then go
to
the
menu bar and click View | Properties. This will bring up the
property
sheet.
Across the Title bar of the property sheet, it should read:
Subform/Subreport: 'the name you want'.

It also works by simply typing Me. in the VBA editor. The period following
the Me will activate the Intellisense feature. You'd just scroll
down
the
list until you find a word which resembles what you think is the name of
your subform.

HTH,
Brian


Brian,
I'm very new to all this. What do I replace [MySubformControl]
with.
Also,
do I use the Main Form Activate event procedure to place the code.
Floyd

:

Floyd,

Try using the form's Activate event procedure. You'll first need
to
set
focus to the subform control, and then go to the last record.

Me.[MySubformControl].SetFocus
DoCmd.GoToRecord , , acLast

Brian


I have many Main Forms, each has a subform for data entry. When I
switch
to a
main form I want cursor to go to last record on that subform.
The
go
to
command does not work for me. Can someone help me with the code.
Thanks,
Floyd
 
Back
Top