Pages In Subform

  • Thread starter Thread starter PC Datasheet
  • Start date Start date
P

PC Datasheet

Is there a way to page through a subform using PageDown and PageUp?

Thanks!

Steve
PC Datasheet
 
When the focus is in a continuous or datasheet style subform, Page Up/Dn
works as you would expect. I assume you mean the case where the subform is
single-form type and Page Up/Dn only moves within the current record.

I haven't tested this, but you could try setting the subform's KeyPreview to
True and using the KeyDown event to trap codes 33 and 34, then using code to
move to the next/previous record.

Something like:
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case 33
DoCmd.GoToRecord , , A_NEXT
Case 34
DoCmd.GoToRecord , , A_Previous
End Select
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

-Ed
 
Ed,

Thanks for responding!

I have a single subform with three pages and would like to page through it.
Your code goes through records and I want to go through pages. The GoToPage
method takes page numbers different than the GoToRecord method that goes to
Next and Previous. Any ideas on how to do the same thing with pages?

Thanks again!

Steve
PC Datasheet
 
Well since it's only three pages, you could use something similar with
either nested Case..Select or If..Then statements. Some like:
'========================
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

Select Case KeyCode
Case 33 'PgDn
If Parent!Me!Page= "Page1"
DoCmd.GoToPage "Page2"
ElseIf Parent!Me!Page= "Page2"
DoCmd.GoToPage "Page3"
'and so on.......................
End Select
End Sub
'==========================

Clumsy, but should work OK for this limited case.
-Ed
 
Thanks again, Ed, for responding!

I sort of see your logic here but what are your thoughts on why you are
using 'Parent' when trying to page through the subform? Do you think this
code will keep anything from happening on the main form?

Steve
 
I'm a bit of a sledge hammer style coder. If you can be sure that the focus
is on the subform, then Me! should suffice, however
Forms!MyMain!MySub.form!MyControl will ALWAYS work.

You'll have to spell out all the possibilities (6) for starting on any of
the 3 pages and moving either Up or Down. Would you want PgDn to cycle from
page 3 to page 1 or just stay on page 3? etc.
-Ed
 
Back
Top