M
Maarkr
I have many forms with the same controls and to advance the forms one by one;
the forms are listed in a table in viewing sequence. One control advances
the forms by looking up the form number and adding one (I made it originally
one sub for each form, then changed it to a public function in a module):
Public Function lblAdvance_Click()
On Error GoTo Err_lblAdvance_Click
Dim stDocName As String, intFormNbr As Integer
intFormNbr = DLookup("FormNo", "TableOfForms", "Form.Name =[FormName]")
intFormNbr = intFormNbr + 1
Debug.Print intFormNbr
stDocName = DLookup("FormName", "TableOfForms", "FormNo=" & intFormNbr)
Debug.Print stDocName
DoCmd.Close
DoCmd.OpenForm stDocName, acNormal
Exit_lblAdvance_Click:
Exit Function
Err_lblAdvance_Click:
MsgBox Err.Description
Resume Exit_lblAdvance_Click
End Function
I tried making a public function using this code for a combo box that you
can select the form you want to go to but it doesn't work:
Public Function CboFormSel_AfterUpdate()
On Error GoTo Err_CboFormSel_AfterUpdate
Dim stDocName As String
stDocName = CboFormSel.Value
DoCmd.Close
DoCmd.OpenForm stDocName
Exit_CboFormSel_AfterUpdate:
Exit Function
Err_CboFormSel_AfterUpdate:
MsgBox Err.Description
Resume Exit_CboFormSel_AfterUpdate
End Function
it can't find the object CboFormSel...
How do I declare it?
Is it normal to use public functions in a module to setup your own objects
that appear on many forms like menu items?? It's such a pain copying and
pasting objects and code that does the same thing on each form. Thanks.
the forms are listed in a table in viewing sequence. One control advances
the forms by looking up the form number and adding one (I made it originally
one sub for each form, then changed it to a public function in a module):
Public Function lblAdvance_Click()
On Error GoTo Err_lblAdvance_Click
Dim stDocName As String, intFormNbr As Integer
intFormNbr = DLookup("FormNo", "TableOfForms", "Form.Name =[FormName]")
intFormNbr = intFormNbr + 1
Debug.Print intFormNbr
stDocName = DLookup("FormName", "TableOfForms", "FormNo=" & intFormNbr)
Debug.Print stDocName
DoCmd.Close
DoCmd.OpenForm stDocName, acNormal
Exit_lblAdvance_Click:
Exit Function
Err_lblAdvance_Click:
MsgBox Err.Description
Resume Exit_lblAdvance_Click
End Function
I tried making a public function using this code for a combo box that you
can select the form you want to go to but it doesn't work:
Public Function CboFormSel_AfterUpdate()
On Error GoTo Err_CboFormSel_AfterUpdate
Dim stDocName As String
stDocName = CboFormSel.Value
DoCmd.Close
DoCmd.OpenForm stDocName
Exit_CboFormSel_AfterUpdate:
Exit Function
Err_CboFormSel_AfterUpdate:
MsgBox Err.Description
Resume Exit_CboFormSel_AfterUpdate
End Function
it can't find the object CboFormSel...
How do I declare it?
Is it normal to use public functions in a module to setup your own objects
that appear on many forms like menu items?? It's such a pain copying and
pasting objects and code that does the same thing on each form. Thanks.