PDA

Click to See Complete Forum and Search --> : Weird Error re: Saving to records.


vbuser1976
Oct 30th, 2000, 02:12 PM
Hi forum buddies!

Please HELP! In my application, I have a form that is basically a data entry screen. Once the user has entered all data requested and clicked save, the form is supposed to save the data in the fields, but I am getting this error when I begin to assign form fields to the fields in SQL:

Run-time error '-2147217887 (80040e21)':
Multiple-step operation generated errors. Check each status value.

Can anyone tell me what this error means, why it occured, and how to solve it? Below is the code I am using just in case you need it.

Thanks again.

Code:

Private Sub ProcessData() 'This procedure processes and saves the inputted data
'to the database
Dim response As Integer
Dim rs As ADODB.Recordset
Dim strSQL As String

txtRepId.Text = "0"
strSQL = "Exec sp_get_report_id " & txtRepId.Text
Set rs = New ADODB.Recordset
Set rs.ActiveConnection = cn
rs.Source = strSQL
rs.CursorLocation = adUseClient
rs.LockType = adLockOptimistic
rs.CursorType = adOpenKeyset
rs.Open , , , , adCmdText

If (txtRepId.Text = 0 Or txtRepId.Text = "") Then
rs.AddNew
End If

With rs
.Fields("AtmId") = txtAtmId.Text 'This is where the cursor stops and gives me above mentioned error.
.Fields("ContactName") = txtContName.Text
.Fields("ContactPhone") = txtContPhone.Text
.Fields("DOccurence") = txtDoccur.Text
.Fields("NOccurence") = txtNature.Text
.Fields("ServiceTech") = lstSvcTech.Text
.Fields("STDate") = txtSvcDate.Text
.Fields("STTime") = txtSvcTime.Text
.Fields("SCrew1") = lstSCrew1.Text
.Fields("SCrew2") = lstSCrew2.Text
.Fields("SCrew3") = lstSCrew3.Text
.Fields("SCDate") = txtSCDate.Text
.Fields("SCTime") = txtSCTime.Text
.Fields("Resolution") = txtResolution.Text
.Fields("Result") = txtResult.Text
.Fields("DateReported") = txtTodaysDate.Text
.Fields("ReportedBy") = txtUserName.Text
.Fields("EmailTo") = lstEmailTo.Text
End With

rs.Update
'txtRepId.Text = rs.Fields("ReportId")
response = MsgBox("Your Report Id is " & rs.Fields("ReportId") & _
".", vbOKOnly, Title:="Your Report Id")
End Sub

Lafor
Oct 30th, 2000, 04:04 PM
Just a few things that pop up from a cursory look at the
code

(By the way, this error just translates to : "Errors Occured") No further indication is given

Now,

Do u have a valid connection in cn?

If u do then
prior to doing

with rs
.fields
etc...

check if the recordset is actually populated

if rs is nothing then
'oops
else
look for .recordcount

and if there is something then proceed

let us know

vbuser1976
Oct 31st, 2000, 11:41 AM
I did what you asked. The connection is valid, the recordset did not equal to nothing and the rs.recordcount is equal to 1 (it is an empty database, so far).

Any ideas?

Lafor
Oct 31st, 2000, 01:36 PM
the AddNew method of the recordset in that case
with rs
.addnew fieldslist

vbuser1976
Oct 31st, 2000, 03:22 PM
Thank you for your help Lafor. Actually, your idea did not solve my problem, but it assisted me in thinking more deeply. What happened was that VB was trying to pass a value with datatype of string to a field that was a date datatype. I changed the datatypes in SQL and it worked!
Thanks again!