Microsoft Access VBA Programming for the Absolute Beginner

If you had run the procedure from the previous section (Sub runFormNY()), you would have noticed an interesting problem: you are locked out from appending new data to the database you are connected to. Nor can you edit data. Notice that the New Record button is grayed out in the form:

Besides the CursorType property, there is a second “Cursor” property you need to deal with: CursorLocation. This defines the location (client side or server side) of the service that tracks the movement of the record pointer through a dataset. By default, without specifying a CursorLocation, the records open in a read-only mode. You can fix that, however, by adding the following highlighted line:

Set recSet = New ADODB.Recordset recSet.CursorType = adOpenKeyset recSet.LockType = adLockOptimistic recSet.CursorLocation = adUseClient

As you can see, the New Record button is now available, as is full editing capability:

Категории