Log in

View Full Version : Solved: Saving a record in VBA



Duncs
03-18-2009, 06:11 AM
I have a database that is used by several people. As part of the operation, three fields are set when the form opens:

Date modified - Today's Date
User ID - Network logon of the user
Status - Initially set to "In Progress"

When the user completes their work, they click a button which sets the Satus to "Completed" and then closes the form. So, what's my problem?

The query behind the form get all records where the Status field is null. If three people access the form, it presents them with the same record. So, I wanted to save the record so that the Status would be set to "In Progress", and no one else would be able to work it, as the query looks for the Status field being null. However, I can't work out how to save the record.

What am I doing wrong? Is there an easier way to do this?

TIA for your help.

Duncs

OBP
03-18-2009, 07:16 AM
Access Record level Locking should prevent 2 people making changes at the same time, the first one will get preference and the second will be informed that the record is being changed. That obviously isn't what you want.
So if you are positive that when someone opens a Record they will always work on it and thus it is "In Progress", i.e. they aren't just "looking" at it, then the answer is to use a VBA Recordset to put those 3 Field's values in to the table. Then anyone running the query will not see that record.
Is that what you want to do?
You can also use VBA to "Save" the record as well, but I am not sure if that will affect what the user is working on.

Duncs
03-19-2009, 04:12 AM
Many thanks for your response.

I got it working by inserting the following line in the forms "On Load" event:

Me.Dirty = False

This solved the problem. Possibly not the most elegant of methods but hey, it works?

Duncs