Problem with before update event in a form in datasheet view

A

Anada

I experienced error messages when I wished to validate data in a text box
through the before update event in Access 2007. After multiple attempts to
find the problem, I finally created the simplest database with only a table
with two variables, a auto numbered and a text field and create a form with
this VBA below in the before update for the text variable to see what was
happening.

Private Sub var1_BeforeUpdate(Cancel As Integer)
If MsgBox("Cancel entry?", vbYesNo) = vbYes Then Cancel = True
End Sub

In a form view (simple or continuous) all works well, but when the form is
in datasheet view, I get the error messages after answering to the msgbox
prompt. Mostly I get "Property not found" and sometimes "The search key was
not found in any record" or "No current record"

I though my Access 2007 had some corrupted files. I reinstalled everything
and the problem is still there!

Does anyone have a clue?
 
E

Evi

I think you should be using the AfterUpdate event for this. I couldn't get
it to work even on a simple form

Evi
 
A

Anada

Thanks for replying.

The VBA I have put here is only to trigger the cancel in the before update
event, just for testing: a message box that when clicked yes, the cancel=true
returns me to my text box control. In my real world application, I have a
more complicated VBA to validate the data before saving the record, so it is
really the before update event that I need. Here I made it simple, just
something cancelling out the event because I get my error messages even at
this level. You could put anything you want as VBA in the before update
event, just make it work in a simple form and then try it in datasheet view
to see if you get also those messages.

What I have done for the time being is to use form error event with
acDataErrContinue to ignore those errors but it is still odd to get those
errors when only in datasheet view. I don't remember getting that before with
previous access version, so I am really perplexed.

Thanks in advance for any further thoughts
 
A

Anada

Hi again,

Just did. No messages, all is ok when using before update or before insert
at the form level. It happens only at the control level in datasheet view.
Oddly enough!

Perhaps I have a corrupted dll somewhere? Probably not in Access, because I
reinstall the whole Office package with all the updates (french version).
 

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