p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Access (http://p2p.wrox.com/forumdisplay.php?f=18)
-   -   Subform Setfocus (http://p2p.wrox.com/showthread.php?t=403)

Steven June 10th, 2003 08:05 PM

Subform Setfocus
 
I'm probably forgetting something really simple, but it escapes me as to what it is.:(

If got a subform, which gets a record inserted into it based on clicking an image on the main form. I want the focus to move to the last record of the subform after the image is clicked.

I've tried DoCmd.GoToRecord , "Subform", acLast
but that doesn't work,
nor does referring to the subform as Form_Subform or Forms!Form!Subform

Can someone tell me where I've been going wrong?

TIA

Steven


I am a loud man with a very large hat. This means I am in charge.

papparuff June 10th, 2003 08:12 PM

You must set the focus to the subform first, then the docmd. Here's what your code would look like:

    ' Set focus to the subform
    NameOfYourSubForm.SetFocus
    ' Move to the last record on the subform
    DoCmd.RunCommand acCmdRecordsGoToLast


John Ruff - The Eternal Optimist :-)

Steven June 10th, 2003 10:46 PM

Doesn't seem to work.
The focus basically stays on the subform the whole time, since there are no focusable controls on the main form - and it still just stays in the first record.

Would the fact that it's a continuous form somehow have something to do with it?

Steven

I am a loud man with a very large hat. This means I am in charge.

papparuff June 10th, 2003 11:14 PM

Try this:

On the Subform's Enter event add the following code:

DoCmd.RunCommand acCmdRecordsGoToLast


John Ruff - The Eternal Optimist :-)

Steven June 11th, 2003 12:38 AM

I'm obviously not that clever - I overlooked a little command after the GoToLast that screwed it all up - DoCmd.Requery

Once again - I'm not that clever

Steven

There are 10 kinds of people in the world - those who understand binary - and those with friends


All times are GMT -4. The time now is 10:03 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.