Link to home
Create AccountLog in
Avatar of wlwebb
wlwebbFlag for United States of America

asked on

Access - Tabbed Form - 2 Tabs - Each Tab has 1 Subform Control - Add New record when going to other Tab

Hello All

Have a Tabbed Form.
Tabbed Form has 2 Tabs
Each Tab has 1 subform as the only Control on the Tab

Tabbed Form name is

Tab 1 is Named Page1; Page Index 0.  
- The Subform control on that Tab is Named

Tab 2 is Named Page2; Page Index 1.  
- The Subform control on that Tab is Named

The form on the First Tab has a Command Button to add the user and I have a Sub that asks do they want to add User to Employees.  If they answer Yes it opens the 2nd Tab and fills in the name etc from the User Form.  Then once they fill out the rest of the Employee Tab Have a Command button on that 2nd Tab Control where they can Save & Add Another User.

What I am attempting is to kick back to a new Record on Tab 1.  I get it to go to Tab 1 but it has the User I just Created previous.  

The Command Button code I have on the 2nd Tab's Subform Control is to go back to tab 1 and Start it with a New Record is:

Private Sub cmdSaveAndAddNewUser_Click()
On Error GoTo cmdSaveAndAddNewUser_Click_Err

    On Error Resume Next
    If Me.Form.Dirty = True Then
        DoCmd.RunCommand acCmdSaveRecord
    End If
    DoCmd.GoToRecord , "[frm_UsersNewTabbed].[sfrm_UsersNew]", acNewRec
    Parent.Page2.Visible = False
End Sub

Open in new window

However, this just goes to Tab 1 but doesn't create a new record. ??????????
Avatar of peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of wlwebb



Thought I had tried that too... so I just tried it again.  When it comes back to that Control on Page1 which is Tab 1 It is showing a new record however all the info from the one just saved is still in the form.   I have the ID field Not Visible so it appeared that I wasn't going to a new record.  I now find that I was I just needed to Clear all those unbound texboxes.

Thanks for the help