[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 518
  • Last Modified:

Tabbed Pages in Access - How to refer to controls on tabbed pages or refresh a tabbed page Access 2010 VBA

Using Access 2010 ,I had 3 separate forms in a database. All was working fine.

Then it was suggested to me that I should use Tabbed Pages for better navigation.

However in so doing this, some of my functionality has gone off the rails.

I created a New form called frm_main. Then on that form I added a Tab Control called TabCtl0.

On that TabCtl0, I have 3 pages. So I basically dragged and dropped the 3 forms on it's own pages.

So far so good, until I started testing some things.

For instance, on Accounts form I had a lookup combobox  that you enter a value and the record is returned on the screen..

The code I had was on the afterUpdate event was

    Dim lnSearchID As Long
    lnSearchID = cmbo_Search.Column(0)
    DoCmd.OpenForm "frm_Master", acNormal, , "l_ID = " & lnSearchID

But now that form "Frm_Master" is sitting on a page on a tabbed control.

How would I get the form to reload and return the correct record? In other words if that form is now on a another form sitting in a tabbed control, on a page??

Another example is on the form load of another form..I have a subform where a field refers to a date selected on the main form

Batch = Forms!frm_invoiceBatch!txt_ID.Value

The error is can't find referenced form "frm_InvoiceBatch", which tells me I need to refer the tab control, then page , then form..just not sure what the syntax would be.

All this worked till I moved the form to the tabbed pages

Any insight or direction would be much appreciated.
0
nomar2
Asked:
nomar2
2 Solutions
 
Jeffrey CoachmanCommented:
This is why you can't just "Drop" forms onto subforms/tabcontrols without understanding "Object Referencing"

There are a lot of possible unknowns here...

Can you post an example db that exhibits this issue?
0
 
peter57rCommented:
First, some general points about referring to subform controls.

The tab control has no bearing on anything.

The issue is that you have gone from 3 main forms, to one main form which holds 3 subforms.

The way you would refer to controls on a subform is quite differrent to the way you refer to controls on a main form.

To refer to a control on a subform you use the syntax...

Forms!Mainformname!subformcontainername.Form!controlname

subformcontainername is the name of the control on the main form that contains the subform.  It might have the same name as the subform but equally it might not.
(The name of the subform is not relevant.)
controlname is the name of the relevant control on your subform

Coming back to your design, though, it sounds to me like you have been given incomplete advice.   If you want the other two forms to match the record in your accounts form then I would say that the Accounts form should be your main form and you drop the other two forms onto that - maybe in a tabcontrol.  But when you add each subform to the accounts main form you will be asked how you want to link the forms together and you can then specify/confirm the matching fields between each pair of forms.  Then the subform data will change to refelect the accounts form record you are looking at.
0
 
Boyd (HiTechCoach) Trimmell, Microsoft Access MVPCommented:
The issues you have described are not related to the TAB control. It is really related to using sub forms and moving reference to control on sub forms.

I regularly convert forms to use a tab control. I take forms with sub forms that are working properly and add a tab control without any issues. Nothing has to be changed in the VBA code.

here is a good reference by fellow Access MVPs: Refer to Form and Subform properties and controls


Boyd Trimmell, Microsoft Access MVP
0
 
nomar2Author Commented:
Used ...
=[Forms]![frm_Main]![Invoices].[Form]![txt_BatchDate]

Just a matter of figuring out the Parent form and subform

Also used  Me.RecordSource = "Select * from tMaster where l_ID = " & lnSearchID  which reloaded the subform to the selected record in the dropdown box
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now