Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old June 10th, 2003, 08:05 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Melbourne, Vic, Australia.
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.
__________________
<hr noshade size=\"1\"><i><font color=\"blue\">I am a loud man with a very large hat. This means I am in charge</i></font id=\"blue\">
  #2 (permalink)  
Old June 10th, 2003, 08:12 PM
Registered User
 
Join Date: Jun 2003
Location: Lakewood, WA, USA.
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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 :-)
  #3 (permalink)  
Old June 10th, 2003, 10:46 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Melbourne, Vic, Australia.
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
  #4 (permalink)  
Old June 10th, 2003, 11:14 PM
Registered User
 
Join Date: Jun 2003
Location: Lakewood, WA, USA.
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try this:

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

DoCmd.RunCommand acCmdRecordsGoToLast


John Ruff - The Eternal Optimist :-)
  #5 (permalink)  
Old June 11th, 2003, 12:38 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Melbourne, Vic, Australia.
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setfocus on Pocket PC rtr1900 Classic ASP Basics 0 October 2nd, 2006 02:29 AM
Setfocus on textbox rtr1900 Classic ASP Basics 2 July 5th, 2006 05:40 AM
ListBox SetFocus Clive Astley Access 7 May 5th, 2004 11:07 AM
Setfocus from button on Commandbar simmy Access VBA 2 December 29th, 2003 11:45 AM
Setfocus from button on Commandbar simmy Access 2 December 29th, 2003 11:31 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.