What OpenRecordSet's "Option" should I use ?

S

S.L.

With DAO 3.6,

I open a form F that bound to table T. This form's RecordType property =
Dynaset, Record Locks = Edited Record. Form is opened without any editing.
Then in another unbound form, I execute

set RS = CurrentDB.OpenRecordSet("select * from T", dbOpenDynaset,
dbDenyWrite, dbPessimistics)

Access error with

3008: The table 'T' is already opened exclusively by another user, or it is
already open through the user interface and cannot be manipulated
programmatically.

My intention is to prevent other user/processes from modify (write and
delete) records in T. What should I use for 3'rd argument without above
error when F is open also.

TIA
 
K

Ken Snell

Try this:

set RS = CurrentDB.OpenRecordSet("select * from T", dbOpenDynaset,
dbReadOnly)
 
S

S.L.

Hi Ken, I miss to explain a little bit more. I'ld like RS to editable also.
By use dbReadOnly, RS can not be edited. I'm very confuse about Options
argument usage. Could you guide me where I can find more information or
sample code and explanation about this Options.

S.L.
 
T

Tim Ferguson

S.L. said:
My intention is to prevent other user/processes from modify (write and
delete) records in T.

Switch off Data Entry, Allow Edits, Allow Deletions, etc from the form.
And/ or set the Recordset Type property to Snapshot.

The final answer is to use Access Security and remove permissions.

HTH


Tim F
 
K

Ken Snell

I'm not clearly understanding what you're doing, I think. You have one form
already open that is based on the table T, and you want to open another form
that also is based on that table. And you want both forms to be able to edit
the same table at the same time? Will they be trying to edit the same
records?

Or do you want the first form to be "readonly" and the second form to be
editable?
 
S

S.L.

Ken Snell said:
I'm not clearly understanding what you're doing, I think. You have one form
already open that is based on the table T,

Yes, it is.
and you want to open another form
that also is based on that table.

No, Second form is an unbound form but have a function that modify the same
record in the first form. That's why I can not use dbReadOnly. First form is
not in editing state, But possible that user may edit that record.

If he is editing but haven't save that record and then use function in
second form, errro is shown. That's ok, it's resonable. But in the case that
record in the first form is not being edited, function in the second form
returns error 3008. That's unacceptable. It seems that I can use neither
dbReadOnly nor dbDenyWrite. What should I do ???
 
K

Ken Snell

Perhaps your function should directly change the values in the controls on
the first form, instead of having the second form edit its recordset. That
should cover both scenarios. Second form then would just be used to accept
the changes and to pass them to the function, which then would write the
values into the first form.
 
S

S.L.

Before you reply, I tested by change my function from DAO to ADO. It work.
That may imply some problem in DAO 3.6 and/or Access 10 Object Library.

Thanks for your time
Suntisuk
 

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