Well - I've finally figured this out. I would like to see if someone could make this better, but it works for now.
Points of interest -
In the first ADO - in order to get the count of records in your database - you need to adOpenStatic or it error's out.
If you have your spreadsheet1 hide the code will error out. You must unhide prior to filling it in.
Me.oSpreadsheet1.Visible = True
I wanted my .mdb column names as my spreadsheets top row so you need to use Field Names.
Private Sub SpreadsheetFill()
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim MySQLcheck As String
Dim i, j As Long
Dim FieldCount, RowCount As Integer
Set rst = New ADODB.Recordset
Set cnn = New ADODB.Connection
MySQLcheck = "Select * from XXXFG_Leadtime"
With cnn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=F:\Open Projects\Sunkist.mdb;"
.Open
End With
rst.Open MySQLcheck, cnn, adOpenStatic
RowCount = (rst.RecordCount)
rst.Close
cnn.Close
Set rst = Nothing
Set cnn = Nothing
Set cnn = New ADODB.Connection
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=F:\Open Projects\Sunkist.mdb"
MySQLcheck = "SELECT [WH_From],[WH_To],[Total_Days_Req],[To_Schedule],[Production_Days],[QA_Incubation],[Load_Time],[On_Water],[Truck_To_Whse] from XXXFG_Leadtime where [WH_From] = '" & UF_WorkOrder.MultiPage1(1).oCB1.Value & "' AND [WH_To] = '" & UF_WorkOrder.MultiPage1(1).oCB2.Value & "';"
Set rst = cnn.Execute(MySQLcheck)
FieldCount = (rst.Fields.Count)
rst.MoveFirst
Me.oSpreadsheet1.Visible = True
Me.oSpreadsheet1.SetFocus
For i = 0 To FieldCount - 1
With Me.oSpreadsheet1.Cells(1, 1).Offset(0, i)
.Value = rst.Fields(i).Name
End With
Next i
rst.MoveFirst
For j = 0 To RowCount - RowCount '(This will return a single record. Replace -RowCount with -1 if you have more than 1 record)
For i = 0 To FieldCount - 1
With Me.oSpreadsheet1.Cells(j + 2, 1).Offset(0, i)
.Value = rst.Fields(i).Value
End With
Next i
rst.MoveNext
Next j
rst.Close
cnn.Close
Set rst = Nothing
Set cnn = Nothing
End Sub