|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
Quote:
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 |
|
#4
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft Access Development > DoCmd.GoToRecord problem in subform |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|