Error '2101' Invalid Setting for Me.Dirty

D

Dymondjack

Question... I'm trying to set Me.Dirty = False on a btnClick event (in hopes
of being able to use DoCmd.GoToRecord,,acNewRec without the 'Cant go to
specified record' error), but when the code runs I get error 2101: "The
setting you entered isn't valid for this property.

Here's the code:

*****
Private Sub btnNxtNo_Click()
Me.Dirty = False '<=== GETS ERROR ON THIS LINE
DoCmd.GoToRecord , , acNewRec
Me.ctlOHRev = 0 'Set the Rev to 0
Me.ctlOHCustID.SetFocus 'Put Focus on Customer field
End Sub
*****
I also tried:

If Me.Dirty = True then
Me.Dirty = False
End If

Either one of these will work if the button is only pressed once, but if no
changes are made to a new record and the button is pressed again is when I
get the 2101 err (or 'Cant go to specified record' if I omit the Me.Dirty
lines)

Any ideas greatly appreciated... I know this is a fairly common scenario but
looking through back posts hasn't seemed to help.

Thanks
Jack
 
T

tina

the problem seems to be when you try to go to a new record, when you're
already on a new record. suggest you check for NewRecord first, as

If Not Me.NewRecord Then
If Me.Dirty Then Me.Dirty = False
DoCmd.GoToRecord , , acNewRec
Me.ctlOHRev = 0 'Set the Rev to 0
Me.ctlOHCustID.SetFocus 'Put Focus on Customer field
End If

hth
 

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