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

Recommended Answers

All 3 Replies

Try using .AddNew rather than .Update

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

do you know the meaning of this error message ?

you will face this error when you try to store value in a field and size of your data is more than the specific field's size.
for example, you are trying to store time in a age field which is probably a numeric field. now if didn't the change default value it should be 10. now if you are inserting time it can be in a format like HH:MM:SSSS which becomes a numeric value also. now each data type has a limit to store values. a numeric field can hold values from -32768 to +32767. now if you try to store any value beyond this range you will face the above error. the same thing is applicable on other data types also.

so check the field size and its data type and then store your value.

regards
Shouvik

Hi,

In 6th line, you need
CustomerInfo.AddNew
(To add new data)

You dont require that, if you are Editting the last record.
And as Shouvik, said, Multi-step error is due to Field data type differences. It is always a good Idea to Set MaxLength property of the Textbox.

Regards
Veena

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.