Hintergrund:
Ich brauche eine Access-Datei zu öffnen und die Informationen zu erhalten, einen Vergleich mit den Daten in meiner Excel-Tabelle zu machen.
Ich verwende Microsoft Office 15.0 Access db engine Objektbibliothek anstelle von Microsoft DAO-Objektbibliothek. Problem:
Während ich verfügbar bin, um alle Daten mit dem folgenden Code einzufügen, beginnt es aus irgendeinem Grund in "Zeile 2" ignoriert Titel.Suche Titel In Acccess DataBase
Sub Sample()
Const PathToDB = "C:\...\AccessFile.accdb"
Const TitleSampleTable = "Sample Table"
Dim BDSample As Database
Dim SampleTable As Recordset
Dim SampleTableDef As TableDef
Dim CounterTitles As Long
Dim CounterRows As Long
Dim ColToPasteIn As Long
Dim RowToPasteIn As Long
Set BDSample = DBEngine.Workspaces(0).OpenDatabase(PathToDB)
Set SampleTable = BDSample.OpenRecordset(TitleSampleTable, dbOpenDynaset)
Set SampleTableDef = BDSample.TableDefs(TitleSampleTable)
For CounterTitles = 0 To SampleTableDef.RecordCount
RowToPasteIn = RowToPasteIn + 1
ColToPasteIn = 1
For CounterRows = 0 To SampleTable.Fields.Count
With Sheets(TitleSampleTable)
.Cells(RowToPasteIn, ColToPasteIn).Value = SampleTable.Fields(CounterRows) 'this is starts in the "body" of access, I can't figure a way to retrieve titles!
ColToPasteIn = ColToPasteIn + 1
End With
Next CounterRows
SampleTable.MoveNext
Next CounterTitles
Set BDSample = Nothing
Set SampleTable = Nothing
Set SampleTableDef = Nothing
End Sub
Beispieldaten in Accesss
Beispieldaten in Excel
Fragen:
Wie kann ich ge t die Titelwerte?
taten Haha, einfach genug! Vielen Dank! – Sgdva