Novice: Getting edit status of current record

  • Thread starter Thread starter Bruce
  • Start date Start date
B

Bruce

I'm learning to use Access...

I have this form with a button labeled "cancel". I just
want to "Undo" and "Close" the form. It works fine
if the user is editing the current record. But if he
hasn't changed anything an error message appears:
The command or action "Undo" isn't available now

How can I determine if it's in edit mode? I looked at
If EditMode = dbEditNone then goto XXX
but I'm not sure how to qualify "EditMode"

Can anyone assist me?
 
Hi, Bruce.

If your form is using a bound recordset, then check the form's "Dirty"
property. Try syntax such as the following:

If (Me.Dirty) Then
' It's in edit mode, so do the "undo" stuff and close the form.
Me.Undo
DoCmd.Close acForm, Me.Name
Else
' It's not in edit mode, so just close the form.
DoCmd.Close acForm, Me.Name
End If

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
 
Perfect! Thanks Gunny!

'69 Camaro said:
Hi, Bruce.

If your form is using a bound recordset, then check the form's "Dirty"
property. Try syntax such as the following:

If (Me.Dirty) Then
' It's in edit mode, so do the "undo" stuff and close the form.
Me.Undo
DoCmd.Close acForm, Me.Name
Else
' It's not in edit mode, so just close the form.
DoCmd.Close acForm, Me.Name
End If

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
 
Back
Top