How do I. . . Prevent a DataSheet View from updating records?

  • Thread starter Thread starter JamesPaulHart
  • Start date Start date
J

JamesPaulHart

Let's start with the fact that I don't know much about Access. After
that. . .

The current situation:

1) I have a Form that is displayed in DataSheet View.
2) The Form is populated from a good old-fashioned query. It has 10
columns - of which I want to protect 9 of from editing (the last one is
an editable text field).
3) I have hooked up the AfterUpdate event so that when the user gets
done editing that field, I want to update various tables based on
conditions in the other 9 (non-editable) fields via VBA.

So far so good - I've managed all the above. My problem is that
apparently The Form (that is being displayed in DataSheet View) *also*
wants to update various records. Unfortunately, it's not smart enough
to know about various scenarios the other fields create - meaning it's
not updating the right tables in the correct manner.

So essentially, I want to stop The Form from doing any updating of
records. I'll handle it by myself. However, I can't figure out how to
do it. I've gone through every property I can think of - but no luck.
For example - if I set the RecordSet type to 'Snapshot' I can't edit
the one field I need to. I also attempted to do a "Me.Dirty = False"
in the AfterUpdate event handler. Although that did get rid of the
"Write Conflict" message I was receiving, it is not preventing Access
from attempting to update the record.

Perhaps I'm missing a property. Alternatively, maybe there's an event
on the form I can hook into and intercept it's attempt to update the
records.

Anybody out there have any suggestions?
 
I'm a bit confused by your post. For any fields you do _NOT_ want to
be editable on your form, you can set the Locked property to True/Yes
and the Enabled property to False/No. then the user can search on
those fields using filter by form, but cannot change the values. If
you let the users edit your tables directly, though, or update those
fields via update queries, then you're stuck.

If you don't want _any_ of the fields to be updatable, set the
AllowEdits property of the subform to False.
 
I do want them to be able to edit 1 of the 10 fields in a given row -
so 9 are locked, 1 is not.

What I don't want is Access to 'automatically' do an update after that
1 field is edited. Because that update is dependant on the values of
other 9 fields, I'm doing it myself in code. I'm just trying to figure
out how to stop Access from doing what it thinks is best.
 
I do want them to be able to edit 1 of the 10 fields in a given row -
so 9 are locked, 1 is not.

What I don't want is Access to 'automatically' do an update after that
1 field is edited. Because that update is dependant on the values of
other 9 fields, I'm doing it myself in code. I'm just trying to figure
out how to stop Access from doing what it thinks is best.

You may want to use an unbound Form, then; display the fields from a
recordset, and do whatever updates you want done when you want them
done.

Datasheet view will be OUT, unless you have a datasheet bound to a
temp table and you take care of migrating the data to and from the
"real" table yourself.

John W. Vinson[MVP]
 
I do want them to be able to edit 1 of the 10 fields in a given row -
so 9 are locked, 1 is not.

What I don't want is Access to 'automatically' do an update after that
1 field is edited. Because that update is dependant on the values of
other 9 fields, I'm doing it myself in code. I'm just trying to
figure out how to stop Access from doing what it thinks is best.

If only one field is editable and enabled then tabbing out of it is going to
leave the record and that is what triggers the save. If you put your code in
the BeforeUpdate event it will always fire prior to the save.
 
Thanks John. I went with the temp table approach and that has gotten
me around my issues.
 

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

Back
Top