Appending and Editing Data


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:

click to expand

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:

click to expand




Access VBA Programming
Microsoft Access VBA Programming for the Absolute Beginner
ISBN: 1598633937
EAN: 2147483647
Year: 2006
Pages: 214
Authors: Michael Vine

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net