Novice: Getting edit status of current record

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?
 
6

'69 Camaro

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.)
 
B

Bruce

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.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top