Good evening all
I wonder if you could help with the following
I hjave the following code which is attached to a "close" button on a form.
When I close the form without any fields being entered I get
a message cant undo etc.So I have added the "Now" to a field
so that it will Undo and then close.
My question is can I do all which is in the code without having to enter that piece first. It just all looks a bit messy and I wondered if any kind person could put me right.
Private Sub close_main_Click()
On Error GoTo Err_close_main_Click
Dim IntResponse As Integer
IntResponse = MsgBox("Exit without saving record ?", vbYesNo + vbDefaultButton1)
If IntResponse = vbYes Then
Me!Flightdate = Now()
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
DoCmd.Close
Else
If IsNull(Me.[Combo41]) Then
Me.Combo41.SetFocus
ElseIf IsNull(Me.[one]) Then
Me.Flightdate.SetFocus
ElseIf IsNull(Me.[two]) Then
Me.Flight.SetFocus
ElseIf IsNull(Me.[AWP]) Then
Me.AWP.SetFocus
ElseIf IsNull(Me.[AWN]) Then
Me.AWN.SetFocus
ElseIf IsNull(Me.[Malus]) Then
Me.Malus.SetFocus
ElseIf IsNull(Me.[threeee]) Then
Me.StaffMember.SetFocus
Cancel = True
etc
I wonder if you could help with the following
I hjave the following code which is attached to a "close" button on a form.
When I close the form without any fields being entered I get
a message cant undo etc.So I have added the "Now" to a field
so that it will Undo and then close.
My question is can I do all which is in the code without having to enter that piece first. It just all looks a bit messy and I wondered if any kind person could put me right.
Private Sub close_main_Click()
On Error GoTo Err_close_main_Click
Dim IntResponse As Integer
IntResponse = MsgBox("Exit without saving record ?", vbYesNo + vbDefaultButton1)
If IntResponse = vbYes Then
Me!Flightdate = Now()
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
DoCmd.Close
Else
If IsNull(Me.[Combo41]) Then
Me.Combo41.SetFocus
ElseIf IsNull(Me.[one]) Then
Me.Flightdate.SetFocus
ElseIf IsNull(Me.[two]) Then
Me.Flight.SetFocus
ElseIf IsNull(Me.[AWP]) Then
Me.AWP.SetFocus
ElseIf IsNull(Me.[AWN]) Then
Me.AWN.SetFocus
ElseIf IsNull(Me.[Malus]) Then
Me.Malus.SetFocus
ElseIf IsNull(Me.[threeee]) Then
Me.StaffMember.SetFocus
Cancel = True
etc