Microsoft Access Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft Access Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 19th, 2005, 09:43 AM
boysherman boysherman is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 5 boysherman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 53 m 3 sec
Reputation Power: 0
DoCmd.GoToRecord problem in subform

Hi,

I am having a problem with a subform going to the last record when it is loaded. When it is loaded separately the DoCmd.GoToRecord , , acLast works fine, but not when the subfrom is loaded as part of the larger form when the larger form is loaded. In this case, the subform opens with the first record displaying. The relationship between the larger form and the subform is a one to many relationship.

Thanks in advance for your help,

bill

Reply With Quote
  #2  
Old July 19th, 2005, 03:49 PM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 5
Bill,

The code you use for your subform should work as you have it posted. What view are you using for your subform, Single, Datasheet or Continuous? Also which event are you placing this code in on your subform.

lwells

Reply With Quote
  #3  
Old July 19th, 2005, 04:10 PM
boysherman boysherman is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 5 boysherman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 53 m 3 sec
Reputation Power: 0
Quote:
Originally Posted by lwells
Bill,

The code you use for your subform should work as you have it posted. What view are you using for your subform, Single, Datasheet or Continuous? Also which event are you placing this code in on your subform.

lwells


actually i found a solution to this problem if i only had a form and then a subform within that form. that solution is as follows: In the OnLoad or OnOpen procedure in the subform
DoCmd.GoToRecord , , acNewRec

In the main form

in the OnCurrent procedure for the main form

Me![subFormName].SetFocus

Me![subFormName].Form![Control].SetFocus

( note the subFormName is as defined in the properties panel for the subform as it is embedded into the main form NOT as is listed in either the database manager or the associated list in VBA)

and in the OnEnter procedure in the embedded subform

DoCmd.GoToRecord , , acNewRec

this actually works. my problem is now that i have a main form. in that main form is a subform. in that subform is another subform. i need to have the last nested subform open to the last record when the main form is opened, but using the method above only works when there is a single nested form.

- bill

Reply With Quote
  #4  
Old July 21st, 2005, 09:28 AM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 5
You were on the right track. Remove all references to the DoCmd.GoToRecord,,acLast in both subforms. In your Main form's on Current Event:

Me!subForm1.SetFocus 'Set the focus to the 1st subform
Me!subForm1.Form!Control.SetFocus 'Set the focus to the subForm primary key field
DoCmd.GoToRecord , , acLast 'Move to the last record
Me!subForm1!subForm2.SetFocus 'Set the focus to the nested subForm
Me!subForm1!subForm2.Form!Control.SetFocus 'Set the focus to the subForm primary key field
DoCmd.GoToRecord , , acLast 'Move to the last record
[MainFormControl].SetFocus 'Return to main form primary key field

This will always show the last record on both subforms as you navigate through the main forms records.
lwells

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft Access Development > DoCmd.GoToRecord problem in subform


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT