Well this is just a variable that will tell me exactly where did the1. lcLngErrLevel indicates what?why u have used this field
error occur.(In our case, its the duplication error although there`s
a wiser way to do that...).
use this one:2. after these statements it is giving the error
On Error GoTo ErrHandler
Set lcObjConn = New ADODB.Connection
lcStrConnString = "Provider=Micorsoft.Jet.OLEDB.3.51;Data Source=c:\winnt\inventory.mdb;Persist Security Info=False"
lcObjConn.Open lcStrConnString
the error is "ado could not find the specific provider"
can u tell me what is wrong in that
VB Code:
lcStrConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" _ & "Data Source=c:\winnt\inventory.mdb;" _ & "User Id=Admin;Password=;"
its specific for ADO and although you are using Access 97, I
guess, you can use OLEDB 4.0 instead of 3.51
try this one:
VB Code:
Private Sub SaveRecords() Dim lcLngi As Long Dim lcStrSQL As String Dim lcFlgUpdate As Boolean Dim lcLngErrLevel As Long Dim lcObjConn As ADODB.Connection Dim lcStrConnString As String On Error GoTo ErrHandler Set lcObjConn = New ADODB.Connection lcStrConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" _ & "Data Source=c:\winnt\inventory.mdb;" _ & "User Id=Admin;Password=;" lcObjConn.Open lcStrConnString With MSFlexGrid1 lcLngErrLevel = 1000 For lcLngi = 1 To .Rows '* Or maybe its (Rows - 1)... lcStrSQL = "INSERT INTO Document(Folder, FileNo, Name) " _ & "VALUES('" & .TextMatrix(lcLngi, 1) & "','" _ & .TextMatrix(lcLngi, 2) & "','" _ & .TextMatrix(lcLngi, 3) & "')" lcLngErrLevel = 1100 '* Execute SQL statement using an ADO Connection lcObjConn.Execute lcStrSQL lcLngErrLevel = 1200 If lcFlgUpdate Then lcLngErrLevel = 1300 lcStrSQL = "UPDATE Document " _ & "SET Folder = '" & .TextMatrix(lcLngi, 1) & "', '" _ & "Name = '" & .TextMatrix(lcLngi, 2) & "' " _ & "FileNo = '" & .TextMatrix(lcLngi, 3) & "'" & "WHERE [insert yout Primary Key Fieldname here] = '" & .TextMatrix(lcLngi, 0) & "'" '* Replace with your primary key here! '* Execute SQL statement using an ADO Connection lcObjConn.Execute lcStrSQL lcLngErrLevel = 1400 End If Next End With Set lcObjConn = Nothing Exit Sub ErrHandler: If lcLngErrLevel = 1100 Then lcFlgUpdate = True Resume Next Else Set lcObjConn = Nothing MsgBox Err.Number & ": " & Err.Description End If End Sub
Your are most welcomed...let me know how it goes![]()




Reply With Quote