Storing active subform in variable 
Author Message
 Storing active subform in variable

I'm having great difficulty storing an active subform name in a
variable.

I have a main form with a tabbed control. Each tab holds a different
subform. The OnClick properties of each tab have the following code:

Set ActiveSubForm = Forms!frmSLPmtSub

This (correct me if I'm wrong) will store the subform name in the
ActiveSubForm variable (defined using Dim ActiveSubForm as Form).

Then, clicking a button on the main form should open a single record
that was selected in the subform. The code is:

Dim stDocName As String
    Dim stLinkCriteria As String
    Dim frmSubFormName As Form
    Dim stSubFormName As String
    Dim ctlCurrentControl As Control

    Set ctlCurrentControl =
Forms!frmSLMain!ActiveSubForm.Form!SalesLedgerID
    stLinkCriteria = "[SalesLedgerID]=" & ctlCurrentControl

    stDocName = "frmSalesLedger"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

I cannot get this to work and I have gone horribly wrong somewhere.

Can anyone suggest a solution or have I become incomprehensible?

Regards

Jon



Mon, 21 Aug 2000 03:00:00 GMT  
 Storing active subform in variable

Use the SourceObject property of the subform control. You can check
the name of the subform control in Design View, and then do something
like:
    Dim sActiveSubForm as String
    sActiveSubForm = Nz(Me![MySubFormControl].SourceObject, "")

Quote:

> I'm having great difficulty storing an active subform name in a
> variable.

> I have a main form with a tabbed control. Each tab holds a different
> subform. The OnClick properties of each tab have the following code:

> Set ActiveSubForm = Forms!frmSLPmtSub

BTW, if you place the subform control on the main form(i.e. not on a
page of the tab control), you can respond to the
Change event of the tab control by loading a different form
into the subform control. This has the advantage of using far
less memory than having a subform on each page of the tab
control, and makes you form much quicker to load.

If the tab control is named tabWot, and the subform control
is fSubGeneric, then the tab control's Change event would be
something like this
-----------------------------------------------------------
    Dim fSub As SubForm

    Set fSub = Me![fSubGeneric]
    Select Case Me![tabWot]
    Case 0          'Product Categories
        fSub.SourceObject = "frmProductCat"
    Case 1          ' Client Type
        fSub.SourceObject = "frmClientType"
    Case 2          ' Client Status
        fSub.SourceObject = "frmClientStatus"
    Case 3          ' System Settings
        fSub.SourceObject = "frmSys"
    End Select
    Set fSub = Nothing
-----------------------------------------------------------
  ,~,_/\
 /      \   Allen Browne
{ Perth  }  Australia
 *_,~~\_/   http://odyssey.apana.org.au/~abrowne/
       v



Tue, 22 Aug 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Store the active worksheet(name) into variable

2. Storing subform name in variable when clicked

3. Link between active form and active subform

4. Referencing a variable name stored in a variable

5. Access a subform's subform variable

6. storing the active cell's location

7. Assign active range to a variable

8. Variable not loaded /active?

9. finding active sheet and global variables

10. use public variables in active sheet


 
Powered by phpBB® Forum Software © phpBB Group