The code below is a complete switchboard solution for me. I have 20 forms
in my database, and it's the only form navigation code that I need.
HTH
UpRider
The three examples are for the Click Event Procedure for a command button on
a form
'Example to swap to a new form and closing the calling form:
Private Sub cmdExit_Click()
Call subSwapForm("frmMiscMaintSwitch", , "Close")
End Sub
'Example to swap to a new form, setting the focus to a control on that form,
and hiding the current form:
Private Sub cmdMemberMaint_Click()
Call subSwapForm("frmDataEntry", "cboNameSearch")
End Sub
'Example to swap to a new form, hiding the current form:
Private Sub cmdSetup02_Click()
Call subSwapForm("frmSetup02")
End Sub
'The three above subs must be in a form's code; i.e. subSwapForm must ALWAYS
be called from a form
'The sub below must NOT be in a form's code, but in a module
Sub subSwapForm(GetForm As String, Optional ToControl As String, Optional
Disp As String)
Dim i As Integer, IsLoaded As Integer
IsLoaded = False
If UCase(Disp) = "CLOSE" Then
Dim cf As Form
Set cf = Screen.ActiveForm
DoCmd.Close acForm, cf.Name
Set cf = Nothing
Else
Screen.ActiveForm.Visible = False
End If
For i = 0 To Forms.Count - 1
If Forms(i).FormName = GetForm Then
IsLoaded = True
Exit For
End If
Next
If IsLoaded = True Then
Forms(i).Visible = True
Else
DoCmd.OpenForm GetForm
End If
If Len(ToControl) > 0 Then DoCmd.GoToControl ToControl
End Sub
CarolM said:
Hi
I dont know if this is even possible but i would like to create my own
switchboard. I have a graphic of a flower which i want to be the main
background. I can then add in either command buttons or links to the rest
of the database.