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 strongm 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 on Subform Continuous Form

Status
Not open for further replies.

traycee

IS-IT--Management
Sep 6, 2001
245
US
Hi All!

I have a Horizontal Tab Navigation Form. I can get the main form, Client, to open to a new record when the database is opened with no problem. Client has a tabbed subform, Programs, which is setup as a continuous form. Whenever they click on the Programs tab, I'd like it to open to a new record automatically. I've tried on current, on click, and on open (DoCmd.GoToRecord , , acNewRec)with no success. Any ideas will be much appreciated.

Thanks.
 
Use the tab's change event and check the value of the tabs. Tabs are zero indexed.
If Me.tabCtlName = 1 Then

'In this case you are clicking on the second tab. Or you can use the actual tab name instead
 
Thanks for the suggestion but it didn't work. My tab control name is Program and it is equal to 1. The navigation form has been killing me, but it's all done except for the tweaking such as go to next record.
 
I am sorry, I did not read that you were using a navigation form. I never use those so I will have to take a look.
 
Just to make sure you are using a Navigation Control and not a standard Tab Control. I cannot really tell. With a Navigation control each "tab" is a navigation button and it has its own events. Just use the click event for the navigation button. Or do you have a navigation for with a form with a tabbed subform (now it is getting confusing)?
 
Definitely confusing. I can provide you with a screen shot which might make it a little clearer.
NavForm
 
So the main form has a navigation control. On the first "page" of the navigation control is a form. This form has a regular tab control. On the second tab is a continous subform.
The fact that this is on a navigation control should be irrelevant.

So click on the "Program" tab control and select the change event. Is your tab control really called "Program"? I would name the tab control something like tabCtlProgram. This is confusing because you say your subform is named Program. Also you use the term "tabbed subform" which is confusing. There is a tab control and you can put subforms on it, but there is not a tabbed subform.

Private Sub tabCtlProgram_Change()
'For test purposes
msgbox "Tab Control Changed"
If Me.tabCtlProgrm = 1 Then
'second tab control because zero indexed
Me.yourSubformName.SetFocus
DoCmd.GoToRecord , , acNewRec
End If

End Sub
 
Also to be clearer/accurate I should call them pages. A tab control has pages and a subform can be put on a page.
 
That worked! Thanks.

You are correct. The name of the tab is ctlProgram.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top