i have typed this code within my form..
Private Sub Command1_Click()
SQL = "select * from cusinfo"
Call connrecordset(CustomerInfo, SQL)
With CustomerInfo
CustomerInfo.MoveLast
!Name = txtName.Text
!Address = txtAddress.Text
!DOB = DTDOB.Value
!Age = DateDiff("yyyy", DTDOB.Value, Now()) + Int(Format(Now(), "mmdd") < Format(DTDOB.Value, "mmdd"))
!Sex = cmbSex.Text
!PassportNo = txtPassport.Text
!Country = txtCountry.Text
!City = txtCity.Text
!TelephoneNo = txtHome.Text
!MobileNo = txtMobile.Text
!Email = txtEmail.Text
.Update
End With
End Sub
Private Sub Form_Load()
Call dbconnection
End Sub
////and in the general module...the connection has been done
see this..
Public SQL As String
Public connParadise As ADODB.Connection
Public CustomerInfo As ADODB.Recordset
Public Sub dbconnection()
'connection to the database
Set connParadise = New ADODB.Connection
connParadise.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\pukoo.mdb;Persist Security Info=False"
connParadise.CursorLocation = adUseClient
connParadise.Open
'database connection established
End Sub
Public Sub connrecordset(tbname As ADODB.Recordset, sequel As String)
'connect to record set
Set tbname = New ADODB.Recordset
With tbname
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.Source = sequel
.ActiveConnection = connParadise
.Open
End With
'connection to the record set established
End Sub
the problem is when i add data into the database it throws me this error at times
Run-time error `-2147217887(80040e21)`
multiple-step operation generated errors.check each status value
and sumtimes it adds records to the database