Subform in a Tab Control not rendering

ayfour

New member
Local time
Tomorrow, 01:50
Joined
Sep 24, 2009
Messages
9
Hi All
(Am working on Access 2007)

I have a subform on each page of a Tab Control on a main form. (There are 6 pages to the Tab Control)

One of my pages (called Org_Details) does not render when I open in Form View - all it shows is a large white rectangle where the image ought to be.

It is the first page to be seen when the form opens.

If I click away to one of the other pages, and then click back to Org_Details, it appears.

I have tried:
1. using any of the other pages as the first page, and there is no problem
2. re-creating the tab page for Org_Details, same problem
3. re-creating the sub-form for Org_Details, same problem
4. re-creating a main form, and Tab Control, same problem

Any ideas on what might be causing this?

Alternatively, at time of load, how do I navigate to one of the other pages, and then back to Org_Details to simulate the click away and click back?

Any help would be most appreciated.

Thanks
K
 
- I've had it before that with multiple subforms on a form, regardless that they appear correctly in design view, when the form is loaded one or more are either not present or have been replaced one for the other.
- I've solved this by removing the subforms from the controls in design view, and loading them at runtime by setting the SourceObject property of the subform controls.
- If you have a tab control with mutiple subforms, one on each page, consider that you can make the tab control transparent, put one subform control behind the tab control. Then, on the tab_Change event change the SourceObject property of the subform control to the name of the subform that is appropriate for the selected tab.

Code:
property get ActivePage as Access.Page
[COLOR="Green"]  'exposes the currently selected tab page[/COLOR]
  with me.tab
    set active page = .pages(.value)
  end with
end property 

private sub tab_change
[COLOR="Green"]  'changes out the subform based on the currently selected tab page
  'uses the name of the page, so you can reorder them and not break the code[/COLOR]
  select case me.activepage.name
    case "pgContact"
      me.genericSFM.sourceobject = "fContactSubform"
    case "pgContactLog"
      me.genericSFM.sourceobject = "fContactLog"
    case "pgWTF"
      me.genericSFM.sourceobject = "fAcronymSubform"
  end select
end sub
 
Thanks for your prompt response lagbolt.

I have tried your code, (I am a little new to Access) and although I don't fully understand the Property section, and put it into my form.

When I try to run it, the main form loads. When I click on one of the tabs, I get:
compile error: syntax error
set active page = .Pages(.Value)

(In this section, I had to change the "me.tab" to be "me.tab_form")

Do you have any further advice? I do not know enough about this to fix it myself.

Your help is most appreciated.
:)
 
My error. In the Property Get statement, 'active page' should be one word.
Code:
  set ActivePage = .pages(.value)
The single line of code that returns the name of the current page of a tab control named MyTab looks like this...
Code:
  debug.print MyTab.Pages(MyTab.Value).Name
...which is hard to read, I think, and if you're using a tab control, this is a piece of information you might wish to refer to regularly in your code. In this case you can provide the form with a custom property which local code--and code on other forms--can consume.
Also, writing a custom property like this would be common practice if you were writing Object Oriented code.
 
Also, if it is a subform that is on the tab control and nothing renders it is likely due to the fact that the subform has no records for the main form (if linked via master/child links) and either the AllowAdditions is set to NO on the main or subform or the recordset for the subform is not updateable.
 
Thanks guys - appreciate the help. Got it working now!

cheers
K
 

Users who are viewing this thread

Back
Top Bottom