H
h2fcell
Hello,
I’m stuck and I can’t get loose. ïŠ
I have a form that opens with the following “On Open†event:
Private Sub Form_Open(Cancel As Integer)
DoCmd.Maximize
DoCmd.GoToRecord , "", acNewRec
DoCmd.Requery "lboItems"
End Sub
If the user makes no changes “form not dirty†and clicks the X on the upper
right corner, the form closes with no problem. If the user makes changes
“form dirty†and clicks X, the form closes and the record is saved, this is
not good.
I’ve created two buttons on the form that work well.
“Save Record†with the following “On Click’ event:
Private Sub cbSaveRec_Click()
Dim myBookingID As String
myBookingID = Me.cboBookingID
DoCmd.GoToRecord , , acNewRec
Me.cboBookingID = myBookingID
Me.lboItems.Requery
Me.cboPaxName.Requery
Me.cboPaxName = Nz(DMin("Name", "qryPaxName"), "")
Me.cboUSDepDate.Requery
Me.cboUSDepDate = Nz(DMin("UsDepDate", "qryDepDate"), "")
Me.tboPaxName = Me.cboPaxName
Me.tboUSDepDate = Me.cboUSDepDate
End Sub
“Close without Saving†with the following “On Click’ event:
Private Sub cbClose_Click()
If Me.Dirty = True Then
DoCmd.RunCommand acCmdUndo
End If
DoCmd.Close acForm, "frmComplaintsEntry", acSaveNo
End Sub
I would like the X to work like my “Close without Saving†button, but when I
added the code to the “On Close†event or the “On Unload’ event I get:
Run-time error ‘2501’:
The Close Action was canceled.
Any suggestions are greatly appreciated.
Thanks.
I’m stuck and I can’t get loose. ïŠ
I have a form that opens with the following “On Open†event:
Private Sub Form_Open(Cancel As Integer)
DoCmd.Maximize
DoCmd.GoToRecord , "", acNewRec
DoCmd.Requery "lboItems"
End Sub
If the user makes no changes “form not dirty†and clicks the X on the upper
right corner, the form closes with no problem. If the user makes changes
“form dirty†and clicks X, the form closes and the record is saved, this is
not good.
I’ve created two buttons on the form that work well.
“Save Record†with the following “On Click’ event:
Private Sub cbSaveRec_Click()
Dim myBookingID As String
myBookingID = Me.cboBookingID
DoCmd.GoToRecord , , acNewRec
Me.cboBookingID = myBookingID
Me.lboItems.Requery
Me.cboPaxName.Requery
Me.cboPaxName = Nz(DMin("Name", "qryPaxName"), "")
Me.cboUSDepDate.Requery
Me.cboUSDepDate = Nz(DMin("UsDepDate", "qryDepDate"), "")
Me.tboPaxName = Me.cboPaxName
Me.tboUSDepDate = Me.cboUSDepDate
End Sub
“Close without Saving†with the following “On Click’ event:
Private Sub cbClose_Click()
If Me.Dirty = True Then
DoCmd.RunCommand acCmdUndo
End If
DoCmd.Close acForm, "frmComplaintsEntry", acSaveNo
End Sub
I would like the X to work like my “Close without Saving†button, but when I
added the code to the “On Close†event or the “On Unload’ event I get:
Run-time error ‘2501’:
The Close Action was canceled.
Any suggestions are greatly appreciated.
Thanks.