MS Access - Forcing an Update

  • Thread starter Thread starter JB
  • Start date Start date
J

JB

Environment: MS Access 97



Problem:

Trying to force a record to update using the recordset.Update property.
What syntax do I need to force a record to be updated? I have searched the
newsgroups and web and haven't found a solution that works.



The following is the syntax from the help file:

recordset.Update (type, force )



The Update method syntax has the following parts.



Recordset: An object variable that represents an open, updatable
Recordset object.



Type: Optional. A constant indicating the type of update, as
specified in Settings (ODBCDirect workspaces only).



Force: Optional. A Boolean value indicating whether or not to
force the changes into the database, regardless of whether the underlying
data has been changed by another user since the AddNew, Delete, or Edit
call. If True, the changes are forced and changes made by other users are
simply overwritten. If False (default), changes made by another user while
the update is pending will cause the update to fail for those changes that
are in conflict. No error occurs, but the BatchCollisionCount and
BatchCollisions properties will indicate the number of conflicts and the
rows affected by conflicts, respectively (ODBCDirect workspaces only).
 
The use of recordset.Update refers to when you create a reocrdset in code,
and thus need to do a update.

The above concept has nothing to do with a form bound to a table, as then
you are not manipulating the data via reocrdsets, but are just using forms.

It is not all clear in which context you are referring to updating a record.
(as there is a zillion ways to update records).

If you want in code to force a disk write for a form that is bound to a
table, and not talking about a reocrdset, then you can use:


me.refresh

In the forms code. Since I always restrict my forms to generally one record,
then out of convenience, I use the above syntax. However, many of the more
experienced regulars here do suggest to use:

if me.Dirty = True then
me.Dirty = False
end if

The dirty property is set = true if data has been modified. If you force
dirty = false, then the only thing ms-access can do is to first force a disk
write. Me.Refresh also works, but can cause other records to be loaded
again. Either of the above will force the current record in a bound form to
disk.

If you are talking about recordsets, and code, then your example of using
recordset.update is correct.
 
Thanks Albert!



I should have included that important piece of info. I am using a recordset
that is not bound to a form.



With your me.Dirty tip I was able to correct the problem, Thanks Again.
 
Back
Top