Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to read an Excel spreadsheet into VB as a Record Set ??!!

Status
Not open for further replies.

garethn

Programmer
Jul 3, 2001
12
GB
I need help opening up an Excel spreadsheet and reading the spreadsheet columns into a records set (as you would with a normal database.
Ive got the basic code but Icant seem to get it to work :


Dim db As Database
Dim rs As Recordset
Dim filepath As String

Dim sheetname As String
Private Sub Command1_Click()

filepath = "\\ltfoxs01\fis$\Terms Discount Test\BudgetZPICS.xls"
sheetname = "BUDGETZPICS$"
'rs.Close
'db.Close

Set db = OpenDatabase(filepath, False, False, "Excel 8.0;HDR=yes;")
Set rs = db.OpenRecordset(sheetname) '<<TYPE MISMATCH ERROR HERE

Do While rs.EOF = False
cboProduct.AddItem (rs!productid)
rs.MoveNext
Loop


End Sub

What am I doing wrong
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top