Link to home
Start Free TrialLog in
Avatar of bejhan
bejhan

asked on

How to open a recordset to only allow deletions and additions?

You can use a combination of the following constants for the options argument.

Constant Description
dbAppendOnly  Allows users to append new records to the Recordset, but prevents them from editing or deleting existing records (Microsoft Jet dynaset-type Recordset only).
dbSQLPassThrough  Passes an SQL statement to a Microsoft Jet-connected ODBC data source for processing (Microsoft Jet snapshot-type Recordset only).
dbSeeChanges Generates a run-time error if one user is changing data that another user is editing (Microsoft Jet dynaset-type Recordset only). This is useful in applications where multiple users have simultaneous read/write access to the same data.  
dbDenyWrite  Prevents other users from modifying or adding records (Microsoft Jet Recordset objects only).
dbDenyRead  Prevents other users from reading data in a table (Microsoft Jet table-type Recordset only).
dbForwardOnly  Creates a forward-only Recordset (Microsoft Jet snapshot-type Recordset only). It is provided only for backward compatibility, and you should use the dbOpenForwardOnly constant in the type argument instead of using this option.  
dbReadOnly  Prevents users from making changes to the Recordset (Microsoft Jet only). The dbReadOnly constant in the lockedits argument replaces this option, which is provided only for backward compatibility.
dbRunAsync Runs an asynchronous query (ODBCDirect workspaces only).  
dbExecDirect  Runs a query by skipping SQLPrepare and directly calling SQLExecDirect (ODBCDirect workspaces only). Use this option only when youre not opening a Recordset based on a parameter query. For more information, see the "Microsoft ODBC 3.0 Programmers Reference."
dbInconsistent  Allows inconsistent updates (Microsoft Jet dynaset-type and snapshot-type Recordset objects only).
dbConsistent  Allows only consistent updates (Microsoft Jet dynaset-type and snapshot-type Recordset objects only).


Above are the only constants to be used in the options argument of the OpenRecordset method. I can't seem to see any combination of these which would allow for only deletions or additions but not edits. How can I achieve this?
Avatar of mbizup
mbizup
Flag of Kazakhstan image

As far as I know, you can't.

How are you using this recordset?
If you are only using this through VBA, you control edits, additions and deletions through the code.

If you are using this to populate a form, you would use the form and control properties to limit the users' access to the data.
Avatar of bejhan
bejhan

ASKER

I am using the recordset as a form recordset to use transactions. But to use transactions I have to open a DAO recordset so I can't use the form's recordsource property, therefore the forms control properties do not apply to the recordset anymore.

I guess on the Current event of my form I could check to check if the record was new and if not just lock the controls but that seems like more work than I should have to do.
ASKER CERTIFIED SOLUTION
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
bejhan
Because you are using unbound forms (from your previous questions) .... neither of these (add only or delete) are an issue because of what mzip eluded to @ http:#a23346364.

It's just that simple.  Nothing is going to happen w/o out code .. .which you are in control of.

mx
Avatar of bejhan

ASKER

But controls on the form are still bound to the recordset. So users still have access to delete and edit records.