D
DJW
I have the following code. I would like to write code to loop through Step1
until the conditions have been met. Once those condition have been met I
would like to do the same for Step2 if the code passes on to that level
instead of going directly to Step3. How do I code this to make it happen?
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Dirty Then 'Checks if any changes were made.
GoTo Question
Else
'Complete original action.
End If
Question:
Message = "Changes made! Do you wish to save?" 'Gives option to save
changes.
If MsgBox(Message, vbQuestion + vbYesNo, "Save Record?") = vbYes Then
GoTo Step1
Else
DoCmd.RunCommand acCmdUndo 'Undoes any changes.
End If
Step1: 'Checks to make sure all required fields contain
information.
If IsNull(Me![Date Submitted]) Then
MsgBox "When was the Item Submitted?"
Me![Date Submitted].SetFocus
ElseIf IsNull(Me![Location Stored]) Then
MsgBox "Where is the Item being Stored?"
Me![Location Stored].SetFocus
ElseIf IsNull(Me![Item Description]) Then
MsgBox "Describe the Item!"
Me![Item Description].SetFocus
ElseIf Not IsNull(Me![Removal Date]) Then
GoTo Step2
Else
GoTo Step3
Step2:
If IsNull(Me![Requested By]) Then
MsgBox "Who requested this item?"
Me![Requested By].SetFocus
ElseIf IsNull(Me![Recieved By]) Then
MsgBox "Who Recieved the Item?"
Me![Recieved By].SetFocus
Me![Record Updated By] = LoginNameField 'Enters variable value
of LoginNameField.
Else
GoTo Step3
Step3:
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
'Saves record.
Exit Sub
End If
End If
until the conditions have been met. Once those condition have been met I
would like to do the same for Step2 if the code passes on to that level
instead of going directly to Step3. How do I code this to make it happen?
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Dirty Then 'Checks if any changes were made.
GoTo Question
Else
'Complete original action.
End If
Question:
Message = "Changes made! Do you wish to save?" 'Gives option to save
changes.
If MsgBox(Message, vbQuestion + vbYesNo, "Save Record?") = vbYes Then
GoTo Step1
Else
DoCmd.RunCommand acCmdUndo 'Undoes any changes.
End If
Step1: 'Checks to make sure all required fields contain
information.
If IsNull(Me![Date Submitted]) Then
MsgBox "When was the Item Submitted?"
Me![Date Submitted].SetFocus
ElseIf IsNull(Me![Location Stored]) Then
MsgBox "Where is the Item being Stored?"
Me![Location Stored].SetFocus
ElseIf IsNull(Me![Item Description]) Then
MsgBox "Describe the Item!"
Me![Item Description].SetFocus
ElseIf Not IsNull(Me![Removal Date]) Then
GoTo Step2
Else
GoTo Step3
Step2:
If IsNull(Me![Requested By]) Then
MsgBox "Who requested this item?"
Me![Requested By].SetFocus
ElseIf IsNull(Me![Recieved By]) Then
MsgBox "Who Recieved the Item?"
Me![Recieved By].SetFocus
Me![Record Updated By] = LoginNameField 'Enters variable value
of LoginNameField.
Else
GoTo Step3
Step3:
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
'Saves record.
Exit Sub
End If
End If