What happened to UNDO?

B

bob

All of a sudden the code below fails to compile and complains that the
UNDO method is not found......This happens on two different PCs.

Ironically, the code works properly - but it just won't compile.

References are fine: no complaints re: missing references.

Anybody got any idea what is going on? Thanks!

Bob Galway

Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_Form_BeforeUpdate
Dim strTemp As String
If Me.Dirty = True Then
strTemp = "Data has changed. Save Changes?"
If MsgBox(strTemp, vbYesNo + vbQuestion, _
"Please Confirm") = vbNo Then
'User has chosen not to save data:
Me.Undo
End If
End If

Exit_Form_BeforeUpdate:
Exit Sub

Err_Form_BeforeUpdate:
MsgBox Err.Description & "---" & Err.Number
Resume Exit_Form_BeforeUpdate

End Sub
 
A

Allen Browne

Bob, that should work.

Is there any chance the form has become unbound?
(It should fail earlier on the Dirty line if this were so.)

Anything that could have changed with permissions?
(Access or Windows, including the folder where the data resides for attached
tables.)

Particularly if the database is being used under different versions, a
decompile might solve it. Here's a standard sequence for the decompile:

1. Uncheck the boxes under:
Tools | Options | General | Name AutoCorrect
In Access 2007, it's:
Office Button | Access Options | Current Database | Name AutoCorrect
Explanation of why:
http://allenbrowne.com/bug-03.html

2. Compact the database:
Tools | Database Utilities | Compact/Repair
or in Access 2007:
Office Button | Manage | Compact/Repair

3. Close Access. Make a backup copy of the file. Decompile the database by
entering something like this at the command prompt while Access is not
running. It is all one line, and include the quotes:
"c:\Program Files\Microsoft office\office\msaccess.exe" /decompile
"c:\MyPath\MyDatabase.mdb"

4. Open Access (holding down the Shift key if you have any startup code),
and compact again.

5. Open a code window.
Choose References from the Tools menu.
Uncheck any references you do not need.
For a list of the ones you typically need in your version of Access, see:
http://allenbrowne.com/ser-38.html

6. Still in the code window, choose Compile from the Debug menu.
Fix any errors, and repeat until it compiles okay.

If this happens with just one form, you could copy all the code to Notepad,
set the form's HasModule property to No, save, compact twice, then paste the
code back into the form's module again.

If the database is used by multiple users at once, it would be a good idea
to split it:
http://allenbrowne.com/ser-01.html
 
B

bob

Allen

many thanks for your response...I did get this to work OK - but I had to
resort to your last option: almost rebuild from scratch (paste code into
fresh new form in a fresh new database). I am surprised that decompiling did
not work - but this was a very stubborn issue.

Any ideas why this happens?

Thanks again

Bob Galway
 

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