Hallo vittorio0,
bei Deinem Code könnte man das so machen:
On Error GoTo ErrorRoutine
' Attribute von frmEditAttr nach MS Access schreiben
Dim oConnect As New ADODB.Connection
Dim oRecSet As New ADODB.Recordset
Dim strDWG As String
Dim sSQL As String
Dim dwgPrefix As String
Dim dwgName As String
Dim DWGpath As String
Dim coderesult As Integer
strDWG = frmEditAttr!F23
'MsgBox strDWG
' build ADO connection string
oConnect.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data"
' MS Access Datenbank Verbindungspfad
oConnect.Properties("Data Source") = "L:\zvmfb\zvmfbdat.mdb"
oConnect.Open
' build the recordset
oRecSet.CursorLocation = adUseClient
oRecSet.CursorType = adOpenKeyset
oRecSet.LockType = adLockOptimistic
sSQL = "Select * From [tbl_Zeichnungen];"
oRecSet.Open sSQL, oConnect
'oRecSet.Find "[F23] = '" & strDWG & "'"
If Not oRecSet.EOF Then ' found a record matching current block ref
dwgPrefix = ThisDrawing.GetVariable("dwgprefix")
dwgName = ThisDrawing.GetVariable("dwgname")
DWGpath = dwgPrefix & dwgName
' read from frmEditAttr and put values in ZVdb
oRecSet!F2 = frmEditAttr.F2.Text ' Titelzeile
oRecSet!F39 = frmEditAttr.F39.Text 'Titelzeile 2
oRecSet!F52 = frmEditAttr.F52.Text 'Titelzeile 3
oRecSet!F3 = frmEditAttr.F3.Text 'Baugruppennummer
oRecSet!F14 = frmEditAttr.F14.Text 'Ersatz für
oRecSet!F10 = frmEditAttr.F10.Text 'Ursprung
If frmEditAttr.F64.Text <> "" then
oRecSet!F64 = frmEditAttr.F64.Text 'a date
else
oRecSet!F64= NULL 'empty date
End if
oRecSet!F66 = frmEditAttr.F66.Text 'b date
oRecSet.Update
Me.Infoline = "Attribute wurden in die Zeichnunsverwaltung eingetragen !"
End If
Set oRecSet = Nothing
Set oConnect = Nothing
ErrorRoutineExit:
Exit Sub
ErrorRoutine:
GoTo ErrorRoutineExit
End If
MsgBox "Error: " & Err.Number & " " & Err.Description
GoTo ErrorRoutineExit
Gruß
MB007
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP