Dim xls As Workbook, app As Excel.Application
Set xls = GetObject(si)
Set app = xls.Application
Dim sh As Excel.Worksheet
Set sh = xls.Sheets(1)
Dim iRow As Integer, iCol As Integer, nCol As Integer
iRow = 1
iCol = 1
Set rs = New ADODB.Recordset
Do
rs.Fields.Append sh.Cells(iRow, iCol), adChar, 128
iCol = iCol + 1
Loop While Len(sh.Cells(iRow, iCol)) > 0
nCol = iCol - 1
iRow = iRow + 1
rs.Open
Do
rs.AddNew
For iCol = 1 To nCol
Debug.Print sh.Cells(iRow, iCol)
If Len(sh.Cells(iRow, iCol)) > 0 Then
rs.Fields(iCol - 1) = sh.Cells(iRow, iCol)
End If
Next iCol
Debug.Print
rs.Update
iRow = iRow + 1
Loop While Len(sh.Cells(iRow, 1)) > 0
xls.Close False
app.Quit
DoCmd.OpenForm "tblReuterFile", acNormal, , , acFormEdit, acWindowNormal
Dim gr As Form
Set gr = Forms!tblReuterFile!grReuterFile.Form
Set gr.Recordset = rs
For iCol = 1 To nCol
Dim ctl As TextBox, lbl As Label
Set ctl = gr.Controls("fld" & CStr(iCol))
Set lbl = gr.Controls("lbl" & CStr(iCol))
ctl.ControlSource = "[" & rs.Fields(iCol - 1).Name & "]"
lbl.Caption = rs.Fields(iCol - 1).Name
Next iCol
|