refering to subform from subform header

silentwolf

Active member
Local time
Today, 07:16
Joined
Jun 12, 2009
Messages
655
Hi guys,

just in the middle of getting some navigations right on my forms and like to set it up more general for Form Appearence and functionality.

What I did is created a sfmHeaderDetails which is in fact just a form with several buttons on it like shown in the Attachment

New Contact, Contact Details, Delete Contact, Edit Contact and another with Back To Main

However to be able to use this sfmHeader on all of my forms which need those buttons I like to create functions that refer to the underlaying
subforms.

For example if I use this sfmHeaderDetails in a form frmCustomerSearch,
I like to make sure that in the subform smfAllCustomers a contact is selected in order to delete him.

Basically to refere to any subform depanding on where the sfmHeaderDetails is includet on a Form.

What I did manage so far is to go back to the mainform.

In a standard module I got following code:
Code:
Public Sub CloseMeAndOpenMain(frmMe As Form)
        On Error GoTo CloseMeAndOpenMain_Error
            DoCmd.Close acForm, frmMe.Parent.Name
            DoCmd.OpenForm "frmDashboard"
        On Error GoTo 0
    Exit Sub
    
CloseMeAndOpenMain_Error:
    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure CloseMeAndOpenMain of VBA Dokument Form_frmContactSearch"

End Sub

In the classmodule of sfmHeaderDetails I have a button called btnReturnToMain

Code:
Private Sub btnReturnToMain_Click()
    CloseMeAndOpenMain Me
End Sub

So if I would have a new form frmCustomerSearch where I put in the form Header my sfmHeaderDetails and pick a customer from sfmAllContacts within the
frmCustomerSearch.

Hope that is well enough explained that someone could give me a hand with that?

Many thanks

Albert
 

Attachments

  • Header.JPG
    Header.JPG
    38.4 KB · Views: 169
Hi Pat,

thanks for your reply!
I just read through it and need a bit more time to get all what you explained right but many many thanks for this!

I will get back to you once I got it working as you suggested!

Cheers
 

Users who are viewing this thread

Back
Top Bottom