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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Goto NewRecord on Form 1

Status
Not open for further replies.

FancyPrairie

Programmer
Oct 16, 2001
2,917
US
I have a form with a subform. For each record in the form, the subform can have 0 to many records. When the user moves to a record in the form, I want the subform to automatically goto a new record. But the user must still have the option of viewing the other records that may exist in the Subform. Therefore, the DataEntry property can not be used.

I have tried setting focus to a control on the subform, and then issuing the docmd.GotoRecord,,acNewRecord command.
But, a new record is added to the form not the subform. This is a very simple thing to do, but I'm drawing a blank as to how to do it.
 
I'd use the Activate event procedure of the subform.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Activate event doesn't get fired as I move from one record to another within the main form.
 
Got it to work, but kind of a kludge. I simply set a public variable to true. Then on the OnCurrent event of the subform, if the variable is true, I issue the command docmd.gotoRecord,,acNewRecord
 
In the Current event procedure of the main form:
Code:
If Not Me.NewRecord Then
  Me![subform control].SetFocus
  Me![subform control].Form![some control].SetFocus
  If Not Me![subform control].Form.NewRecord Then
    DoCmd.RunCommand acCmdRecordsGoToNew
  End If
End If

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top