Solved

Automatically changing subforms

Posted on 2004-04-27
4
335 Views
Last Modified: 2008-03-06
Hi.  I've overloaded a tab page with way too many pages, each of which contains a few calculated subforms which, overall, is overwhelming my application.

As opposed to cutting up the tabs into several, smaller tab pages, I wanted to see if I could just automatically change subforms via a script -- that is, simulate how a web page works with frames (i.e., you have a master "form", and depending on what buttons you press, it will open deferent "subforms" in a designated subform area).

Was wondering if I could click on a button, and have it change the data source of the subform (e.g., subforma, subformb, subformc)?  This would save me a lot of recoding time, and presumably reduce the burden on the application by keeping closed subforms that I'm not using anyway.

Many thanks!

Farron
0
Comment
Question by:flevy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 3

Expert Comment

by:SiJP
ID: 10930397
Yep there is....

... in its simplest terms...

Private Function fChangeSubForm

 Dim mySubfrm as String
 mySubfrm = fsubSomeFormName

 subfrmobject.SourceObject = mySubFrm

End Function

0
 
LVL 3

Accepted Solution

by:
SiJP earned 250 total points
ID: 10930502
Bit more detail...

If you want to change the subfrm by selecting it, you could have somthing like this:

Create a Combo box on your form (cboSubfrms)
Create a subfrm (Subfrm)

add code:

Private Sub cboSubfrms_Change()
 subfrm.SourceObject = cboSubfrms.Value
End Sub

Private Sub Form_Open(Cancel As Integer)
    cboSubfrms.ColumnCount = 2
    cboSubfrms.RowSourceType = "Value List"
    cboSubfrms.ColumnWidths = "0;4"
    cboSubfrms.RowSource = "fsubmysubfrm; My Sub Form; fsubmysubfrmagain; Another Sub Form"
End Sub

0
 

Author Comment

by:flevy
ID: 10941800
Works great -- thanks.  One follow-on question...

When I change the subforms, how do I then grab values from that subform?  Whenever a new subform comes up, I wanted to grab a specific calculation from that subform.  However, I'm having difficulty doing that.  Logically, I'd like code to perform the following function:

For Form/subformA combination:
Form.sfAdatacapture = Form.subformA.finalcalc

Then, when Form/subformB displays, capture similar data:
Form.sfAdatacapture = Form.subformB.finalcalc

Problem is, once a new subform is in place, it doesn't seem to recognize the traditional Form.subform.control path.  Does the original Form.subform persist as some kind of mask, such that I need to code the controls on various subforms the sames way?

Thanks!
0
 

Author Comment

by:flevy
ID: 10942725
Just tested the 'mask' theory another way, and it works.

Thanks for the initial solution.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question