J
jeh
Command buttons on my switchboard launch Event Procedures sub1 and
sub2. One button opens the form frmMyForm in data entry mode, the
other uses a query to select particular records that need updating and
then opens the same frmMyForm with the appropriate record(s)
available. So far so good.
frmMyForm has three command buttons whose logical functions are:
* Reopen the form (for another data entry or for another record to
edit, depending on whether the form was opened by sub1 or sub2)
* Save the entries, close the form and return to the Switchboard
* Save the entries and close the database.
The only way I can think of to get this to work when two subroutines
open the same form involves the following code (considerably
simplified from the original) for sub2, and similar but simpler code
for sub1.
Private Sub Sub2()
Dim strCrit As String
1 strCrit = InputBox("Please enter Data Identifier")
DoCmd.OpenForm "frmMyForm", , , strCrit, , acDialog
' Insert code to either
' Go to 1 (to start the routine again)
' Close frmMyForm and return to Switchboard, or
' Close the database
End Sub
My problem arises at completion of data entry/editing, when I'm ready
to close (or hide?) frmMyForm. Can, or should, I attempt to have each
of the three closing buttons return a different value to Sub2 (which I
can then use to switch control) or should I attempt to have each
button enter sub2 at a different entry point somewhere below the
DoCmd.OpenForm statement? In either case, how can one do this?
I know that one obvious answer is to use two versions of the form.
I've been doing this for a while but have had trouble with maintenance
issues when changes occur.
Apologies if this type of problem has been answered before - I've just
not found the right keywords to find an example
TIA John
sub2. One button opens the form frmMyForm in data entry mode, the
other uses a query to select particular records that need updating and
then opens the same frmMyForm with the appropriate record(s)
available. So far so good.
frmMyForm has three command buttons whose logical functions are:
* Reopen the form (for another data entry or for another record to
edit, depending on whether the form was opened by sub1 or sub2)
* Save the entries, close the form and return to the Switchboard
* Save the entries and close the database.
The only way I can think of to get this to work when two subroutines
open the same form involves the following code (considerably
simplified from the original) for sub2, and similar but simpler code
for sub1.
Private Sub Sub2()
Dim strCrit As String
1 strCrit = InputBox("Please enter Data Identifier")
DoCmd.OpenForm "frmMyForm", , , strCrit, , acDialog
' Insert code to either
' Go to 1 (to start the routine again)
' Close frmMyForm and return to Switchboard, or
' Close the database
End Sub
My problem arises at completion of data entry/editing, when I'm ready
to close (or hide?) frmMyForm. Can, or should, I attempt to have each
of the three closing buttons return a different value to Sub2 (which I
can then use to switch control) or should I attempt to have each
button enter sub2 at a different entry point somewhere below the
DoCmd.OpenForm statement? In either case, how can one do this?
I know that one obvious answer is to use two versions of the form.
I've been doing this for a while but have had trouble with maintenance
issues when changes occur.
Apologies if this type of problem has been answered before - I've just
not found the right keywords to find an example
TIA John