OK...building on previous suggestions I was able to make some of my global modules work fine...especially after learning to pass forms as Forms instead of strings. However, although the first part of my routine below works by passing OldForm as a Form, I cannot figure out how to make the two highlighted areas work using the OldForm and NewForm. I can only make it work using strings...or by typing them in directly (which defeats the purpose of the global module). In other words...if I pass OldForm and NewForm as Forms...the top part works. If I pass them as Strings the bottom part works. What can I do to make both work?
Public Sub GoToOtherForm(NewForm As Form, FormID As String, FormFocus As String, OldForm As Form, CheckField As Control)
Call GoToOtherFormMessageBox
If MessageBox = vbCancel Then
DoCmd.GoToControl (strLastFocus)
Else
If MessageBox = vbOK Then
Call OrdnanceClearActiveItem
If CheckField.Enabled = True Then
OldForm.ClearFormButton.Enabled = False
OldForm.ClearActiveItemButton.Enabled = False
ElseIf CheckField.Enabled = False Then
OldForm.ClearFormButton.Enabled = True
OldForm.ClearActiveItemButton.Enabled = False
End If
DoCmd.OpenForm "ScenarioOverviewForm", , , , acFormEdit, , strScenario_ID
DoCmd.GoToControl (FormID)
DoCmd.FindRecord strScenarioID, , True, , True, , True
DoCmd.GoToControl (FormFocus)
AllowClose = True
DoCmd.Close acForm, "ScenarioOrdnanceForm"
End If
End If
End Sub
Public Sub GoToOtherForm(NewForm As Form, FormID As String, FormFocus As String, OldForm As Form, CheckField As Control)
Call GoToOtherFormMessageBox
If MessageBox = vbCancel Then
DoCmd.GoToControl (strLastFocus)
Else
If MessageBox = vbOK Then
Call OrdnanceClearActiveItem
If CheckField.Enabled = True Then
OldForm.ClearFormButton.Enabled = False
OldForm.ClearActiveItemButton.Enabled = False
ElseIf CheckField.Enabled = False Then
OldForm.ClearFormButton.Enabled = True
OldForm.ClearActiveItemButton.Enabled = False
End If
DoCmd.OpenForm "ScenarioOverviewForm", , , , acFormEdit, , strScenario_ID
DoCmd.GoToControl (FormID)
DoCmd.FindRecord strScenarioID, , True, , True, , True
DoCmd.GoToControl (FormFocus)
AllowClose = True
DoCmd.Close acForm, "ScenarioOrdnanceForm"
End If
End If
End Sub