Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
chobo
Starting Member
11 Posts |
Posted - 2004-03-02 : 22:03:53
|
Hi, I want to make a form in access 2003 so that I can access an excel worksheet, and display a message box for a certain cell that will display the contants of the cell. The following is code for what I want to do the only difference is that it is referencing a database file at that path whereas I need to access an excel worksheet and have it do the same thing. Any help is appreciatedPrivate Sub cmdOutside_Click()Dim dbs As New ADODB.ConnectionDim rst As New ADODB.Recordsetdbs.ConnectionString = "provider=microsoft.jet.oledb.4.0;" & _"data source = C:\Documents and Settings\Administrator\My Documents\Cisy 540\misc\540wk3query.mdb;"dbs.Openrst.Open "select firstname from employee order by firstname", dbs, adOpenDynamic, adLockOptimisticMsgBox rst!firstnamerst.CloseSet dbs = NothingEnd Sub |
|
AjarnMark
SQL Slashing Gunting Master
3246 Posts |
Posted - 2004-03-04 : 13:37:13
|
It's been a couple of years since I last did this, but you can use the jet.oledb.4.0 provider to open a spreadsheet and select from it. Your best bet is probably to search Microsoft's site. From memory, I think in place of the table name (employee) you put the name of the worksheet tab within the workbook you're opening.Just a warning though, I ran into an anomoly where the driver would scan the first x number of rows (I think the default is 10) to determine the datatype. This can cause you problems when, for instance, it determines that a column is numeric, and then one of the rows has non-numeric data in it. In that case, it returns Null. There's a registry setting somewhere to tell your computer to scan the entire file before deciding on data types. Because of this problem, I'm not a big fan of accessing a spreadsheet this way.--------------------------------------------------------------Find more words of wisdom at [url]http://weblogs.sqlteam.com/markc[/url] |
 |
|
|
|
|
|
|