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

Your code merely creates a connection to a database, it doesn't open any tables.

Replace your line:

' open a recordset

With these lines:

Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
With rs
.Source = "SELECT * FROM " & ans
.ActiveConnection = cn
.Open
End With
' Do something with recordset
rs.Close
cn.Close

--

"George" wrote in message ...
Hi there, I am using this code to connect to the access
database but its not opening the tables I want to open:
Sub Auto_Open()
Dim cn As ADODB.Connection
ans = InputBox("What Table you want to analyze?")
' connect to the Access database
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=C:\FolderName\DataBaseName.mdb;"
' open a recordset
End Sub
Pls if you have any information that I can use to fix this
problem let me know

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
Connecting Excel sheets to Access Tables??? Dave Excel Discussion (Misc queries) 1 January 9th 09 11:44 PM
Excel in macro and connecting to a network drive question Mike S. Excel Discussion (Misc queries) 3 November 8th 08 02:51 AM
Call an Access macro from an Excel macro Jason W Excel Discussion (Misc queries) 1 May 1st 08 08:33 PM
Macro Error When Connecting to Hidden Sheet Wuddus Excel Discussion (Misc queries) 5 August 3rd 06 03:34 PM
Launch Macro in Access via Macro running in Excel??? dgrant Excel Programming 1 September 24th 03 01:38 PM


All times are GMT +1. The time now is 06:27 AM.

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

About Us

"It's about Microsoft Excel"