All,

Have a set of nested forms/subforms in this order:

frmMain => sfmMain => ifmTABset => sfmUSR => sfmSETcfg

where sfmMain & sfmUSR are the control fields containing the subforms being called and the TAB control TabCtl0 resides in the TABBED form of ifmTABset.

I am trying to open the 5th TAB in the TABBED form and set it's subform with the following code:

Form_frmMain.sfmMain.Form![TabCtl0].Value = 5
or
        Form_frmMain![sfmMain].Form.ifmTABset![TabCtl0].Value = 5

        Form_frmMain![sfmMain].Form.ifmTABset![sfmUSR].SourceObject = "sfmSETcfg"
        Form_frmMain![sfmMain].Form.ifmTABset![sfmUSR].SetFocus

The last two lines are correct, but getting:

1. "not valid for this property",
2. "can't find field".

errors respectively. If I put the last two line first and I click the TAB after clearing the error the right subform shows.

The customer DB is designed with FE/BE config with central BE DB on the server, so writing an automated table relink subroutine. Have global of "LinkStat" initialized as False, with:

if LinkStat = true then
....
end if

in each "OnLoad" event for each screen, which is necessary as all forms are unbound, so have to execute for .rowsource of each combobox in each form in the onload for each.

When the link refresh runs, without error, the LinkStat is set True, but it is having trouble calling this config screen, on fail, where the user can "Browse" for the location of the BE file and sets it in a local table.

The config screen is in the fifth TAB of the TABBED form (which is the set of "SETUP" screens) and the 3rd subform in the SETUP Form, normally selected with button on lefthand side, see the ConfigScreen screen shot. The initial run always fails to link, so a manual call to the subroutine is needed, which is from the button in the Tools Screen (5th subform) per screen shot.

I know it is a syntax thing, but my mind is toast today, so please help. Just not seeing the obvious today.

Thanks!

TBN

Recommended Answers

All 2 Replies

Tab controls are interesting in that you rarely need to do anything at all with them or reference them. In your case you need to set focus to tab 5 and then refer to the subform on subform. You have to set focus first. I will show you a way to refer to forms and controls which most don't use but with nested subforms it works well.

First the set focus

Forms!frmMain.ifrmTABset.Pages(4).SetFocus

Since the pages are zero based, page 5 would be 4 in the scheme. You can also use just the page name instead of the tab control name. So if your page was actually named page5 then you would be able to go with

Forms!frmMain.page5.SetFocus

And then you need to refer to the subform item

Forms("frmMain").Controls("sfrmMain").Form.Controls("sfrmUser").SourceObject = "sfmSETcfg"

I think you may want to read my tutorial on subforms. It helps with understanding when to use the .Form. and when not to.
You can find it here:
Easy Way to Remember Subform Syntax

All,

Got this one fixed.

Thanks!

TBNK

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.