Code:
' ZV mit der geladenen Zeichnung lesen und in frmEditAttrX eintragen
' Attribute von MS Access holen und in der Form einlesen
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
Dim RecCnt As Long
Dim i As Long' welche Zeichnung is im Autocad geladen?
strDWG = ThisDrawing.GetVariable("dwgname")
strDWG = Mid(strDWG, 1, (Len(strDWG) - 4))
' build ADO connection string
oConnect.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data"
' MS Access Datenbank Verbindungspfad
oConnect.Properties("Data Source") = "L:\x\xx.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.MoveFirst
oRecSet.Find "[F23] = '" & strDWG & "'"
'MsgBox "Gefunden mit .Find " & oRecSet!F23 & " mit find.. d " & strDWG
If Not oRecSet.EOF Then ' found a record matching current block ref
dwgPrefix = ThisDrawing.GetVariable("dwgprefix")
dwgName = ThisDrawing.GetVariable("dwgname")
DWGpath = dwgPrefix & dwgName
If Nz(oRecSet!F76, "") <> "" Then
'MsgBox oRecSet!F76, , "SF-wechsel zu vorhandenem layout..."
ThisDrawing.ActiveLayout = ThisDrawing.Layouts(Nz(oRecSet!F76, ""))
'MsgBox ThisDrawing.Layouts.Count, , "Anzahl Layouts"
End If
' requires update ?
'If oRecSet!requpd = False Then
If oRecSet!optAction = 0 Then
'MsgBox "Zeichnung braucht kein update", vbInformation, dwgPrefix & dwgName
Set oRecSet = Nothing
Set oConnect = Nothing
Unload frmEditAttrX
Exit Sub
End If