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

Go To New Record in Subform 2

Status
Not open for further replies.

maxhugen

Programmer
May 25, 2004
498
AU
A button on a main form "invoice" is "Add Record". I'd like to move to a new record in a subform "invoice_item", but without necessarily setting focus to that subform, so I can't use:

Code:
DoCmd.GoToRecord acDataForm, "invoice_item", acNewRec

Any thoughts please?

MTIA

Max Hugen
Australia
 
How are ya maxhugen . . .

If your mainform/subform are properly linked with [blue]Master/Child[/blue] link properties, when you goto a new record on the mainform the subform should do the same.

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
So apparently you just want to "see" the new record since you don't want to set focus to the subform. I think you will need to set focus to the subform, move to the new record, and set focus back to where it was originally.

Duane
Hook'D on Access
MS Access MVP
 
Hi Aceman, the main/subform aren't linked. The main is just a 'container' for a number of related subforms... a subform list of items, and then further details (subforms) that relate to that item.

Duane, that's the way I'm currently doing it, and using DoCmd.RunCommand acCmdRecordGotToNew when in the subform.

I was just wondering if I'd missed something... but I guess not.

Thanks!

Max Hugen
Australia
 
maxhugen . . .

As an option you could run the following code in the subform code module ...
Code:
[blue]Public Sub GotoNewRec()
   If Not Me.NewRecord Then DoCmd.RunCommand acCmdRecordsGoToNew
End Sub[/blue]
... from the button on your mainform with:
Code:
[blue]   [[purple][B][I]subFormName[/I][/B][/purple]].Form.GotoNewRec[/blue]
No need to set focus to the subform ...

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Excellent, Aceman! There are usually a number of ways to achieve something in Access - this looks just the ticket.

Many thanks again!

Max Hugen
Australia
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top