Setup ado recordset
Expand|Select|Wrap|Line Numbers
- Private Sub Form_Open(Cancel As Integer)
- Set rst = CreateObject("ADODB.Recordset")
- With rst
- .ActiveConnection = CurrentProject.AccessConnection
- .Source = "SELECT * FROM MapIndex"
- .LockType = 3 'adLockOptimistic
- .CursorType = 1 'adOpenKeyset
- '.CursorLocation = 3 ' adUseClient
- .Open
- End With
- Set Me.Recordset = rst
- End Sub
- 'Function to add record and save record
- Private Sub cmdAddRecord_Click()
- If cmdAddRecord.Caption = "Add Record" Then
- UnlockRecords
- rst.AddNew
- GivenName.SetFocus
- ElseIf cmdAddRecord.Caption = "Save Record" Then
- rst.Update
- LockRecords
- End If
- End Sub
- Private Sub cmdEditRecord_Click()
- If cmdEditRecord.Caption = "Cancel" Then
- rst.CancelUpdate
- LockRecords
- End if
- End Sub
Can anyone help as I've been stuck with this error for a few days now. i've already passed the time to hand in database for testing. Thanks heaps.