i've seen several posts on this issue, but often they are more complex that what I'm trying to achieve. many of them are calls from asp pages, but I am working right within my own access db (2002) environment.
The goal is to understand ADO in Jet environment, as I have plans to eventually work with connecting to larger databases. Thus I know I can workaround with DAO, but I don't want to
anyway, here is my code, which just takes info from textboxes on form and updates a table.
the culprit is addNew - can't get it to work! - it also could be that cnADO.Execute statement - I tried cnADO.Open -but it didn't work Can somebody help me with my syntax?
much obliged!
I am a nobody, and nobody is perfect; therefore, I am perfect.
The goal is to understand ADO in Jet environment, as I have plans to eventually work with connecting to larger databases. Thus I know I can workaround with DAO, but I don't want to
anyway, here is my code, which just takes info from textboxes on form and updates a table.
Code:
Public Sub addNewAuto()
Dim strSQL As String
Dim strPolID As String
Dim datEffDate As Date
Dim datExDate As Date
Dim intAutoNum As Integer
Dim strVehDescrip As String
Dim strVin As String
Dim cnADO As ADODB.Connection
Dim rsADO As ADODB.Recordset
Set cnADO = CurrentProject.Connection
strPolID = Me.txtPolID.Value
datEffDate = Nz(Me.txtEffDate.Value, Date)
datExDate = Nz(Me.txtExpDate.Value, Date)
intAutoNum = Me.txtVehicleNum.Value
strVehDescrip = Nz(Me.txtDescrip.Value, "")
strVin = Nz(Me.txtVin.Value, "")
strSQL = "SELECT tblAutoSchedule.ID, tblAutoSchedule.PolicyID, tblAutoSchedule.EffDate, "
strSQL = strSQL & "tblAutoSchedule.ExDate, tblAutoSchedule.Number, tblAutoSchedule.Year, "
strSQL = strSQL & "tblAutoSchedule.VehDescrip, tblAutoSchedule.Vin "
strSQL = strSQL & "FROM tblAutoSchedule;"
Set rsADO = cnADO.Execute(strSQL)
rsADO.AddNew
rsADO("PolicyID") = strPolID
rsADO("EffDate") = datEffDate
rsADO("ExDate") = datExDate
rsADO("Number") = intAutoNum
rsADO("VehDescrip") = strVehDescrip
rsADO("Vin") = strVin
rsADO.Update
End Sub
the culprit is addNew - can't get it to work! - it also could be that cnADO.Execute statement - I tried cnADO.Open -but it didn't work Can somebody help me with my syntax?
much obliged!
I am a nobody, and nobody is perfect; therefore, I am perfect.