Open subform with a button

jaanisf

Registered User.
Local time
Today, 03:19
Joined
Apr 29, 2003
Messages
32
Hi!
Seems like a simple thing but I do not know, how to make it. Well, I have an index form with a set of buttons. On pressing a button I want a subform to come up with another set of buttons according to the button pressed in an index form. And I want there a subform with no buttons when an index form opens. So, what I should write behind my first button's On Click, presuming I want a subform [sbfrmName1] to come up, and what I should write behind my index form's On Open, presuming I want a subform [sbfrmIndex] to come up?
Thanks in advance!
 
Have you tried using the 'Visible' or 'Hide' settings?
If you set your subform and button properties to Not Visible and then write code from your OnClick Event of the button to set them to Visible = True, then that may work. Remember to set the focus or use the Me. prefix
 
Well, since I need 5 subforms in the same place, it would be a confusion to work. Isn't it possible to place a variable behind subforms Source Object somehow?
 
This is a shortened example of how I change the "source" object of an
unbound subform to display the data selected from a combo box named
cbImportedFileData. Basically I am using one subform within the form to
alternate between 12 different subforms that are used to display the
imported tables data.
Code:
Private Sub cbImportedFileData_AfterUpdate()
On Error GoTo Err_cbImportedFileData_AfterUpdate
    
    Beep
    
    Select Case cbImportedFileData
    
    Case 1
        If cbImportedFileData = 1 Then
        SubForm.Visible = True
        lSubForm.Caption = "Imported XYZ Data"
        SubForm.SourceObject = "subtXYZ"
        End If
    
    Case 2
        If cbImportedFileData = 2 Then
        SubForm.Visible = True
        lSubForm.Caption = "Imported 123 Data"
        SubForm.SourceObject = "Subt123"
        End If
    
    End Select
    
    Forms!fImportedData!SubForm.SetFocus
    
Exit_cbImportedFileData_AfterUpdate:
    Exit Sub
    
Err_cbImportedFileData_AfterUpdate:
    MsgBox Err.Number & " - " & Err.Description
    Resume Exit_cbImportedFileData_AfterUpdate
    
End Sub
HTH
 
Good, this one works, thank you ;)
Private Sub btnIenaakumi_Click()
Me!subf.Visible = True
Me!subf.SourceObject = "SubfIenaakumi"
Forms!Index!subf.SetFocus
End Sub
 

Users who are viewing this thread

Back
Top Bottom