Okay. I get the gist of what you guys are saying but me putting that in action is still outside my skill set. I have a very rudimentary understanding of classes and objects and such but not enough to wrap my head around it and since this is likely the most complex work I will ever do again, if I even do anything at all. I need a little more lower level help.
To that end, I have posted one of the particular form modules below. In the first command section and the last command section, I use the Dim function to define the PrevForm (stCallingForm as many seem to use) and then since I can exit this form in multiple conditions, one saves and exits and the other cancels and exits, I currently define the Dim variable twice, once for each command.
What davegri says makes sense I just don't know how to execute that or how the syntax should be put in place. That's where I need some help here. If someone can show me with this code, that would be great.
Code:
Option Compare Database
Private Sub Command_Save_Exit_Click() 'Closes Hive Inspection Entry / Edit and returns to previous form
Dim PrevForm As String
If Not IsNull(Me.OpenArgs) Then 'Confirms previous form was documented
PrevForm = Me.OpenArgs
DoCmd.Close acForm, "F_Log_Inspection_Hive_Entry_Edit"
DoCmd.OpenForm PrevForm
Else 'If previous form was not documented then returns to Inspection Main
DoCmd.Close acForm, "F_Log_Inspection_Hive_Entry_Edit"
DoCmd.OpenForm "F_Log_Inspection_Main"
End If
DoCmd.Requery
End Sub
Private Sub Command_Save_Add_Click()
If Me.Dirty Then
Me.Dirty = False
End If
DoCmd.GoToRecord , , acNewRec
End Sub
Private Sub Command_Cancel_Click() 'Removes any changes or entries and returns to the previous form
Dim PrevForm As String
If (Forms!F_Log_Apiary_Entry_Edit.Dirty = -1) Then 'Removes entries to cancel without saving
DoCmd.RunCommand acCmdUndo
End If
If Not IsNull(Me.OpenArgs) Then 'Confirms previous form was documented
PrevForm = Me.OpenArgs
DoCmd.Close acForm, "F_Log_Inspection_Hive_Entry_Edit"
DoCmd.OpenForm PrevForm
Else 'If previous form was not documented then returns to Inspection Main
DoCmd.Close acForm, "F_Log_Inspection_Hive_Entry_Edit"
DoCmd.OpenForm "F_Log_Inspection_Main"
End If
DoCmd.Requery
End Sub
This is not fully tested code so there may be other errors I have to deal with still but defining the variable is what I need the help with at the moment.
Thanks