Paul Clark
Registered User.
- Local time
- Today, 13:31
- Joined
- Oct 30, 2011
- Messages
- 23
I total novice at VBA
I am trying to code a button to modify (the last) record in a subform list and then add a new record based on values in unrelated or unbound fields on the button form.
The following code is based on the first of two YouTube tutorials (this bit on the edit) and looks like it should work. Except that my Access 2010 with Visual Basic for Aplication v7 does not recognise the type definition Database or Recordset
Any help with this will greatly appeciated
I am trying to code a button to modify (the last) record in a subform list and then add a new record based on values in unrelated or unbound fields on the button form.
The following code is based on the first of two YouTube tutorials (this bit on the edit) and looks like it should work. Except that my Access 2010 with Visual Basic for Aplication v7 does not recognise the type definition Database or Recordset
Code:
Private Sub ANOwner_Click()
Dim cn As Integer
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset(OwnershipLog)
For cn = 0 To rs.Recordcount = 1
If rs.Fields("Chassis_No") = Me.CChassisNo Then
rs.Edit
rs.Fields("Current Owner") = ""
rs.Update
End If
rs.MoveNext
Next i
Debug.Print db
End Sub