Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default access to excel

i'm trying to view some data from access in excel. i'm using code found
on this site written in excel as shown below but excel seems to fail to
recognise the datatype "Database". Any ideas?

Sub DAOCopyFromRecordSet() '"C:\db1.mdb" As _ String,
"dbt_Pruefbericht" As String, "dbf_MessDaten" As _ String, Range("A1")
As Range)
' Example: DAOCopyFromRecordSet "C:\FolderName\db1.mdb", "TableName",
"FieldName", Range("C1")

Dim db As Database
Dim rs As Recordset
Dim intColIndex As Integer
Set TargetRange = TargetRange.Cells(1, 1)
Set db = OpenDatabase("C:\db1.mdb")
Set rs = db.OpenRecordset("dbt_Pruefbericht", dbOpenTable) _ ' all
records
'Set rs = db.OpenRecordset("SELECT * FROM " & TableName _ & " WHERE
" & FieldName & " = 'MyCriteria'", dbReadOnly) ' filter _ records
' write field names
For intColIndex = 0 To rs.Fields.Count - 1
TargetRange.Offset(0, intColIndex).Value =
rs.Fields(intColIndex).Name
Next
' write recordset
TargetRange.Offset(1, 0).CopyFromRecordset rs
Set rs = Nothing
db.Close
Set db = Nothing
End SubDatabase
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default access to excel

cheers Tom it now recognises Database as well as other objects
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Query from Access into Excel cause Access to go to read only T Stephens Excel Discussion (Misc queries) 0 March 24th 09 04:17 PM
Can Excel access data from Access?! Al Excel Discussion (Misc queries) 5 April 5th 08 03:52 PM
Macro to check data from excel list against access query and return value back to excel dreamkeeper Excel Worksheet Functions 0 October 31st 07 07:26 PM
Access Form In An Access Report (SubForm) Question Gary Links and Linking in Excel 0 January 27th 06 05:54 AM
export access to excel. change access & update excel at same time fastcar Excel Discussion (Misc queries) 0 June 24th 05 09:27 PM


All times are GMT +1. The time now is 11:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"