Notes on ADO from other projects Please use speaker notes for additional information!
Update
Private Sub cmdAdd_Click() ADODonor.Recordset.AddNew End Sub Private Sub cmdDelete_Click() ADODonor.Recordset.Delete ADODonor.Recordset.MoveFirst End Sub Private Sub cmdMoveFirst_Click() ADODonor.Recordset.MoveFirst End Sub Private Sub cmdMoveLast_Click() ADODonor.Recordset.MoveLast End Sub Private Sub cmdMoveNext_Click() ADODonor.Recordset.MoveNext End Sub Private Sub cmdMovePrevious_Click() ADODonor.Recordset.MovePrevious End Sub Private Sub cmdUpdate_Click() ADODonor.Recordset.Update End Sub Code
Private Sub Form_Load() Dim strConnectStr As String databasepath = App.Path If Right(databasepath, 1) <> "\" Then databasepath = databasepath & "\" End If databasepath = databasepath & "donor.mdb" strConnectStr = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" strConnectStr = strConnectStr & databasepath ADODonor.ConnectionString = strConnectStr 'ADODonor.CommandType = adCmdText 'ADODonor.RecordSource = "SELECT * from Donor2000 ORDER BY DIdno" ADODonor.CommandType = adCmdTable ADODonor.RecordSource = "Donor2000" ADODonor.Refresh ADODonor.Recordset.Sort = "DIdno" End Sub Code Another approach. Making this form portable.
PrDonorinGrid.vbp
Connection string is done in Form_Load to make the program portable. The caption code puts a caption over the specified columns. The visible code eliminates two columns. In this program we do not see street address or zip. Note also the width code which sets the width of two columns.
PrDonorinGrid.vbp The column information specified in the code on the previous slide is implemented.
PrADOACDstuy.vbp The beginning steps to add a new record.
PrADOACDstuy.vbp In form load, the connection string and record source are established. The recordset is also sorted by idno (the key field). Here I add a new record with AddNew, populate it with data and then Update the field that I added.
PrSQL4ADOy.vbp
PrSQL5ADOy.vbp
PrSQL6ADOy.vbp
Bookmark or hold the current location. When no match is found the holdBookmark is used.