Adding new record for tabbed forms

petro62

New Member
Joined
Jul 15, 2013
Messages
46
Office Version
  1. 365
Platform
  1. Windows
I am back.

I am not sure if I went about this right, but I created all my individual input pages/forms. I then created a tabbed form and dragged those forms to their specific tab. I have a button on my menu that when clicked will open this user input form and close the main menu form. Along with that though I would like to get all the forms on new record (it currently just loads the first record in the database).

I tried with the Macro GoToRecord. I set the type as form, the object name as the form (Project Information) and set Record to New.

When I run the macro I get an error saying Project Information isn't open. It is open in the tabbed User Input Form, but the actual form itself is not open. I tried putting in the User Input for and that doesn't do anything, but doesn't return an error. So I am stuck on how to solve this. I am not sure if it is the way I inserted the forms into the tabbed form or what. I upload an image of the Macro setup.
 

Attachments

  • macro image.JPG
    macro image.JPG
    21 KB · Views: 12

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
I think you mean you dragged forms on to a navigation form. "Tab" is probably one of the most confusing terms in Access, so that needs to be cleared up.
Tab view - when you open a form, there is a tab at the top, much like tabbed pages in a browser.
Then there is the tab control - each "tab" is, more accurately, a "page" on the tab control
Then there is the navigation form with tabs, which when clicked on, load a form in a single control called the navigation subform control

So in the latter case, you choose a tab and its form opens (but as a subform). You choose another tab, the first form closes and the chosen one opens. If there is a way to propagate a value from the first form to the second one, I'm not sure - but I'm not sure you want to do that either. I gather from you post that you want to open these forms to a new record. You should be able to do that by setting the form Data Entry property to Yes in design view, which should open the form to add, but not view or edit existing records. You can also GoTo a new record:

Private Sub Form_Load()
DoCmd.GoToRecord , , acNewRec
End Sub

but keep in mind that if you're using a nav form, you have to consider what I mentioned about how the nav form behaves. I suppose navigation forms are ok if you really understand them, but most experienced developers will roll their own, probably mainly due to not being able to pass info from one subform to the other.
 
Upvote 0
Solution
I think you mean you dragged forms on to a navigation form. "Tab" is probably one of the most confusing terms in Access, so that needs to be cleared up.
Tab view - when you open a form, there is a tab at the top, much like tabbed pages in a browser.
Then there is the tab control - each "tab" is, more accurately, a "page" on the tab control
Then there is the navigation form with tabs, which when clicked on, load a form in a single control called the navigation subform control

So in the latter case, you choose a tab and its form opens (but as a subform). You choose another tab, the first form closes and the chosen one opens. If there is a way to propagate a value from the first form to the second one, I'm not sure - but I'm not sure you want to do that either. I gather from you post that you want to open these forms to a new record. You should be able to do that by setting the form Data Entry property to Yes in design view, which should open the form to add, but not view or edit existing records. You can also GoTo a new record:

Private Sub Form_Load()
DoCmd.GoToRecord , , acNewRec
End Sub

but keep in mind that if you're using a nav form, you have to consider what I mentioned about how the nav form behaves. I suppose navigation forms are ok if you really understand them, but most experienced developers will roll their own, probably mainly due to not being able to pass info from one subform to the other.
Yeah sorry access terms are still new to me. I created a tab control. And it has 7 pages(tabs). When I click a button that says add new project it will go to the first page of that form and start a new record/entry. All 7 of the pages go into the same table.
 
Upvote 0
I don't use macros, but what I see there seems to parallel what I'd expect to see in code. Can you upload a pic of your form in design view, just to be sure? Can you see the form on a page when Access says it isn't open? If yes, then at this point it's a bit of a mystery. You might also try using the expression builder to see if that resolves your issue. I think a pic might help somewhat, though.
 
Upvote 0
I don't use macros, but what I see there seems to parallel what I'd expect to see in code. Can you upload a pic of your form in design view, just to be sure? Can you see the form on a page when Access says it isn't open? If yes, then at this point it's a bit of a mystery. You might also try using the expression builder to see if that resolves your issue. I think a pic might help somewhat, though.
 

Attachments

  • user input.JPG
    user input.JPG
    203.5 KB · Views: 19
Upvote 0
I will add that the whole purpose of this form/database is to either enter in a new project and the information that goes with it or edit and existing project.
 
Upvote 0
The purpose doesn't shed any light on the immediate problem for me but I think I see the problem. That pic does look like it's a tab control, which has a kind of odd reference syntax and behaviour when drilling down to the form on a page. Try referencing your form like this:

Forms!NameOfMainFormHere.NameOfSubformOnPageHere.Form.ControlName Or Property goes here

This is a form/tabcontrol/subformControl/subform hierarchy. When you dragged the form onto a page, Access automatically created a subform control to put it in. Unfortunately it will likely have the same name as your subform, so keep that in mind going forward.

If you wanted to get the value of a control on that form it would be as
Something = Forms!NameOfMainFormHere.NameOfSubformControlOnPageHere.Form.ControlName

However it seems you want to set a form property (DataEntry) so
Forms!NameOfMainFormHere.NameOfSubformControlOnPageHere.DataEntry = True

Note that the page id doesn't enter into this.
Not sure that the vba syntax will help you directly if you're using macros, but at least you now know the hierarchy, and if using the Expression Builder as I mentioned, you should be able to create that path for your macro. Thing is, in your posted macro you have table as the type whereas I think it should be "form" and you should be able to type in the correct reference using the syntax I showed you.

Lastly, an oddity of subforms is that they are not loaded, thus they are not part of the collection of open forms, thus you cannot treat them as such. However, you can refer to them via the collection of forms in the project. I mention that because it's possible that you could get the same error about a subform not being open, but since you seem to be referring to a table instead of a form, I can't tell if that's relevant for your issue.
HTH.
 
Upvote 0
The purpose doesn't shed any light on the immediate problem for me but I think I see the problem. That pic does look like it's a tab control, which has a kind of odd reference syntax and behaviour when drilling down to the form on a page. Try referencing your form like this:

Forms!NameOfMainFormHere.NameOfSubformOnPageHere.Form.ControlName Or Property goes here

This is a form/tabcontrol/subformControl/subform hierarchy. When you dragged the form onto a page, Access automatically created a subform control to put it in. Unfortunately it will likely have the same name as your subform, so keep that in mind going forward.

If you wanted to get the value of a control on that form it would be as
Something = Forms!NameOfMainFormHere.NameOfSubformOnPageHere.Form.ControlName

However it seems you want to set a form property (DataEntry) so
Forms!frmTabControl.frmCartTimer.Form.DataEntry = True

Not sure that the vba syntax will help you directly if you're using macros, but at least you now know the hierarchy, and if using the Expression Builder as I mentioned, you should be able to create that path for your macro. Thing is, in your posted macro you have table as the type whereas I think it should be "form" and you should be able to type in the correct reference using the syntax I showed you.

Lastly, an oddity of subforms is that they are not loaded, thus they are not part of the collection of open forms, thus you cannot treat them as such. However, you can refer to them via the collection of forms in the project. I mention that because it's possible that you could get the same error about a subform not being open, but since you seem to be referring to a table instead of a form, I can't tell if that's relevant for your issue.
HTH.
Thanks for all the great info. I will have to take a look at it in the morning. Instead of dragging them into the tab control is there a way I can convert all of my individual forms into a tab control without having to make them all new. Maybe it doesn’t even make a difference but I wasn’t sure if the way I made this just over complicated it or not.
 
Upvote 0
is there a way I can convert all of my individual forms into a tab control without having to make them all new.
Sorry, I don't understand what that means. Convert? Make new? When you drag a form onto a page, it's not a new form - it's the same form that was in the nav pane that you dragged it from. Post 6 suggests you do need a main form (details of the one)/subform (details of the related many). Whether or not you need to split the "many" on to several pages I don't know. Usually that is done when either the one or the many has too many fields to show in one view. However, the reason for too many fields is often because of lack of normalization of the db tables. In that case, the use of pages is a symptom of a problem, not of good design decisions.
 
Upvote 0
The purpose doesn't shed any light on the immediate problem for me but I think I see the problem. That pic does look like it's a tab control, which has a kind of odd reference syntax and behaviour when drilling down to the form on a page. Try referencing your form like this:

Forms!NameOfMainFormHere.NameOfSubformOnPageHere.Form.ControlName Or Property goes here

This is a form/tabcontrol/subformControl/subform hierarchy. When you dragged the form onto a page, Access automatically created a subform control to put it in. Unfortunately it will likely have the same name as your subform, so keep that in mind going forward.

If you wanted to get the value of a control on that form it would be as
Something = Forms!NameOfMainFormHere.NameOfSubformControlOnPageHere.Form.ControlName

However it seems you want to set a form property (DataEntry) so
Forms!NameOfMainFormHere.NameOfSubformControlOnPageHere.DataEntry = True

Note that the page id doesn't enter into this.
Not sure that the vba syntax will help you directly if you're using macros, but at least you now know the hierarchy, and if using the Expression Builder as I mentioned, you should be able to create that path for your macro. Thing is, in your posted macro you have table as the type whereas I think it should be "form" and you should be able to type in the correct reference using the syntax I showed you.

Lastly, an oddity of subforms is that they are not loaded, thus they are not part of the collection of open forms, thus you cannot treat them as such. However, you can refer to them via the collection of forms in the project. I mention that because it's possible that you could get the same error about a subform not being open, but since you seem to be referring to a table instead of a form, I can't tell if that's relevant for your issue.
HTH.
So I converted my macro over to visual basic so that way I could try and follow your example. So as you saw in the picture I have 7 pages/tabs with multiple fields in each one. The main form would be User Input (this is the tab control) and then the 7 subforms (Project Info, Team, Schedule, Spending, Plant Req, Checklist, Results).

Following your code:
Forms!NameOfMainFormHere.NameOfSubformControlOnPageHere.DataEntry = True

Forms!User Input.Project Information.DataEntry = True but that doesn't work and also you mentioned that the name of the page id isn't used. So I am confused what the .NameofSubformControlonPageHere. is. Also would I have to do this for every page in the tab control?

I also tried Forms!User Input.TabCtl10.DataEntry = True The tabctl10 is the name that shows up on the User Input screen when I click outside of the tabbed area (the orange selection box grabs everything).
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,821
Messages
6,121,759
Members
449,048
Latest member
excelknuckles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top