Tab Control Form - Goto New Record

G

Guest

I have a Main form with 6 tab sub forms. I need the sub forms to load to a
new record. The following code does not work.


Private Sub TabControl_Change()
Dim CurConn As ADODB.Connection
Dim CommitNumber As New ADODB.Recordset

Set CurConn = CurrentProject.Connection

On Error GoTo ErrorHandler
With Me
Select Case .TabControl.Value
Case 0 'Clients


Case 1 'Pair_Outs

DoCmd.GoToRecord , "", acNewRec

Any help would be appreciated.
 
J

John Vinson

The following code does not work.


What "doesn't work"? If you're trying to navigate to records on a
Subform, the tab control is irrelevant - you need to somehow reference
the (undescribed and unmentioned) subform in your code. Since it's not
at all clear how your form is structured or just what you want to
accomplish, it's hard to say what you should change!

John W. Vinson[MVP]
 
G

Guest

I have a Main form with a combo box which is the id number for that client
and 6 tabs with each one as a subform. Each tab form operates as a
calculator and the info is loaded into separate tables. When you chose an
id out of the combo box, I need the tab subform to load at a new record
without hitting the cmd new button.

Which event would it go?

DoCmd.OpenForm "Forms!frmMaintenance!frmPairOut", acNormal
DoCmd.GoToRecord , , acNewRec

Does it not have to do with the Change Event?
 
J

John Vinson

I have a Main form with a combo box which is the id number for that client
and 6 tabs with each one as a subform.

A tab "as" a subform? Sorry, tabs don't work that way. A Tab Control
has NOTHING to do with data or subforms. Its *only* function is to
share screen space. You can put subforms on a tab, or you can put
listboxes or checkboxes or anything else; it's just a way of arranging
controls on the screen.

I'm guessing that you have six Subforms; the fact that they are
located on different pages of a tab control has absolutely no bearing
on record navigation.
Each tab form operates as a
calculator and the info is loaded into separate tables.

I have no idea what you mean by "operates as a calculator".
When you chose an
id out of the combo box, I need the tab subform to load at a new record
without hitting the cmd new button.

Which event would it go?

DoCmd.OpenForm "Forms!frmMaintenance!frmPairOut", acNormal
DoCmd.GoToRecord , , acNewRec

This code has nothing to do with tab controls or with subforms; it
opens a NEW FORM, or it would if you passed it "frmPairOut" as the
first argument.
Does it not have to do with the Change Event?

Nope. The Change Event fires at every keystroke in the combo box.

I *THINK* - and I'm not at all certain - that what you want to do is
have the six Subforms each have the name of the combo box as their
Master Link Field, so that when you select a new record in the combo,
the subforms' record sources reflect that change. At the most, you
might need to use the combo box's AfterUpdate event (which fires when
a new record has been selected) to Requery each subform:

Me!subMySubform1.Form.Requery

where subMySubform1 is the Name property of the subform control (which
might or might not be the same as the name of the form within that
control). The tab page number - and the tab control itself - is
irrelevant to this action.

John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

tab control form - goto new record 1
Jet Engine Error Message 2
Displaying A Recordset 1
Open new form 1
Code to open a query 2
Connection Problem 1
Tab Control Problem (Access 2K) 8
Access forms "add record" 5

Top