Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scroll down a subform automatically

Status
Not open for further replies.

hgrafen

Programmer
Jul 20, 2004
9
DE
Hi experts,

we have a form with an subform on it. The subform is larger (higer) than the subform control in which it is embedded. So it's okay that a vertical scrollbar is appearing.

When the form opens we need to show a control on then subform, which isn't visible before a user handles this scrollbar.

How can we do this scrolling automatically by VBA code or a makro when the form opens?

Thanks,
Hansjoerg.
 
Have you tried to play with the SetFocus method of this control ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Yes, I did.

Setting the focus results in the questioned control having the focus then, but remains in the non-visible area "down under" of the subform.

What we are looking for is a method to directly access the scrollbar.

Hansjoerg.
 
No more ideas? It's really frustrating, i'll loose my job if this bushshit doesn't work ...
 
hgrafen,

I know most programmers will bad-mouth the use of SendKeys, but in this case it should do the trick.

In code, you just need 2 lines to set focus to the subform, then use the Page Down Key with SendKeys -

Code:
subformname.SetFocus

SendKeys "{PGDN n}"

' where n is the # of times to simulate scrolling down with the Page Down Key.  You may have to experiment to get the correct # and spacing.

If you're not familiar with SendKeys, see the Access Help file. Hope this helps!

huskerdon
 
Hi

Another one for you to try, as the axe falls

Me.MySubFormControl.FORM.recordsetClone.MoveLast



Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
What kind of control on the subform are you trying to show? The 2 suggestions you've been given work just fine on tests I've done. If the control is a command button, text box, combo box, check box, etc., then simply setting focus to it should automatically scroll down so that control is visible. Remember, to set focus to the control on the subform, you'll have to use code such as this (from the main form):

Me.subformname,.Form.controlname.SetFocus

(Of course, SetFocus won't work if the control is a label, image, etc.)

Also, if the subform has a vertical scroll bar already, doing the SendKeys trick should make it scroll down.
Are you actually trying these suggestions?
 
Sorry, that should be

Me.subformname.Form.controlname.SetFocus

where "subformname" is the name of the subform container on the main form, and "controlname" is the name of the control on the subform that you want to show.
 
Yes, i've tried these suggestions. But Sendkeys doesn't work. No keys are sended.
 
No, the moving the current record mothod is not appropriate in this case, because it is an unbound form.

greets,Hansjörg
 
Hi

In that case

Private Sub Form_Load()
Me.frmSubForm.Form.cmdTest.SetFocus
End Sub


in the main form, works

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top