Log in

View Full Version : Solved: Data provider returned E_Fail status



Movian
12-20-2010, 03:36 PM
Hey i have a .ADP with a SQL backend and i am stumped.

A small minority of my clients have a problem with a particulate function in my system where by after closing a form it will generate an error stating.

"Data provider returned E_Fail status"

I have tried everything i can think of and am hoping someone can steer me in the right direction.

Here is the code and support vars and subs



Option Compare Database
Option Explicit
Dim EditLabel As Boolean
Dim Statement1 As String

Private Sub SaveAndClose_Click()
Dim counter As Integer, myrs As New ADODB.Recordset

CreateAndExit
Forms("FrmMain").Controls("fsubmodule").Controls("InitImp3") = Statement1
Me.List1RowSource = Me.List1.RowSource

myrs.Open "SELECT * FROM [TreatmentPlan] WHERE [TreatmentPlan].[MedicalID] = '" & Me.MedicalID & "'", CurrentProject.Connection, adOpenKeyset, adLockOptimistic

If myrs.RecordCount = 1 Then
For counter = 1 To Me.List1.ListCount
myrs.Fields("TxPlanText" & CStr(counter)).Value = Me.List1.ItemData(counter)
Next
End If

myrs.Update
myrs.Close
Set myrs = Nothing

DoCmd.Close acForm, "dxCheckForm"
End Sub
Private Sub CreateAndExit()
Dim counter As Integer
Dim actcount As Integer
actcount = 0

On Error Resume Next
If Not Me.List1.ListCount = 0 Then
For counter = 0 To Me.List1.ListCount - 1
Select Case Me.Frame0
Case 1
Statement1 = Statement1 & Chr(13) & Chr(9) & Chr(149) & " " & Me.List1.ItemData(counter)
Case 2
actcount = actcount + 1
Statement1 = Statement1 & Chr(13) & Chr(9) & CStr(actcount) & ". " & Me.List1.ItemData(counter)
End Select
Next
Else
Statement1 = ""
End If

actcount = 0
End Sub

As always any help is appreciated.

Movian
12-22-2010, 08:35 AM
Ok after many hours of trying to figure this out.

It turns out that the problem was the field that the text was being placed into was linked to a nvarchar(255) field in the database and it had more that 255 characters. After changing the field type to text the problem apears to be resolved.

Wish they would send a less ambiguous message EG, "Data to large for field".