Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vba in forms question

Status
Not open for further replies.

nevstic

Instructor
Jul 30, 2002
98
GB
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top