Hi folks, I'm new to your forum and need some help figuring out the 2003 equivalence to the 97 recordset code I am used to.
I would like to add, update, delete data to my tables using recordsets.
I learnt Access 97 at college 10 yrs ago and haven't used it for many years. Now I have to do a project at work using Access 2003. I find that code syntax from old college projects doesn't work in 2003. From what I've read it is because of a change from DOA to ADODB
This is a typical example of what I would do on Access 97
What is the equivalent code to do this in Access 2003?
This example is an unbound form for tracking projects, and has a combo box to lookup the project then display its data. This code updates the changes from the textboxes to the table.
I have scoured the forum here and bought 3 books a week ago:
Special Edition Using MS Office Access 2003 / Roger Jennings/Que ;
Beginning Access 2003 VBA / Denise Gosnell/ Wrox ;
Access 2003 Inside Out/ John Viescas/ Microsoft ;
They all have snippets of code referring to the ADODB which have things like :
but they don't have an example similar enough for me to figure out how to do it. The books also vary how and where they write the Dim cnConnection type info so it's a bit confusing.
Any help is much appreciated in advance
TerriAnn
I would like to add, update, delete data to my tables using recordsets.
I learnt Access 97 at college 10 yrs ago and haven't used it for many years. Now I have to do a project at work using Access 2003. I find that code syntax from old college projects doesn't work in 2003. From what I've read it is because of a change from DOA to ADODB
This is a typical example of what I would do on Access 97
What is the equivalent code to do this in Access 2003?
This example is an unbound form for tracking projects, and has a combo box to lookup the project then display its data. This code updates the changes from the textboxes to the table.
Code:
Private Sub cmdUpdate_Click()
Dim rstSET As Recordset, dbDataBase As Database
Dim strcriteria As String, intCustomerNumber As Integer
Dim intAnswer As Integer
Set dbDataBase = CurrentDb()
Set rstSET = dbDataBase.OpenRecordset("Projects", dbOpenDynaset)
strcriteria = "ProjectNumber =" & ProjectNumber
rstSET.FindFirst strcriteria 'Find Project
If rstSET.NoMatch Then
MsgBox "No Such Project..."
Else
'Prepare the current record for editing
rstSET.Edit
'make the necessary changes to the record
rstSET!ProjectName = ProjectName
rstSET!ProjectedCost = ProjectedCost
rstSET!StartDate = StartDate
rstSET!ProjectedEndDate = ProjectedEndDate
rstSET!Status = Status
rstSET!EndDate = EndDate
rstSET!ProjectDescription = ProjectDescription
'Save the changes to the current record
rstSET.Update
End If
rstSET.Close
dbDataBase.Close
Exit_Rtn:
ProjectNumber.SetFocus
Exit Sub
End Sub
I have scoured the forum here and bought 3 books a week ago:
Special Edition Using MS Office Access 2003 / Roger Jennings/Que ;
Beginning Access 2003 VBA / Denise Gosnell/ Wrox ;
Access 2003 Inside Out/ John Viescas/ Microsoft ;
They all have snippets of code referring to the ADODB which have things like :
Code:
Dim cnConnection as ADODB.Connection
Dim rsRecordset as ADODB.Recordset
Set rsRecordset = New ADODB.Recordset
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & CurrentProject.Path & "\Ch5CodeExamples.mdb;"
etc..
Any help is much appreciated in advance
TerriAnn