LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Excel VAB+ADO connect ACCESS with SQL

Hi! I try to develop a search interface by using Excel, but I have no idea
how can I make the SQL where clause become dynamic. Thanks a lot.
The VBA code is below:

Sub ado()
Dim AlexCon As ADODB.Connection
Dim AlexRS As ADODB.Recordset
Af = Cells("a10").Value
Ase = Cells("b10").Value
Set AlexCon = New ADODB.Connection
AlexCon.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=d:\test.mdb"
Set AlexRS = New ADODB.Recordset
With AlexRS
.ActiveConnection = AlexCon
.Source = "SELECT * FROM test WHERE B=" &Af &"Or A=" &Ase
.Open
End With
Range("A1").CopyFromRecordset AlexRS
AlexRS.Close
Set myRecSet = Nothing
AlexCon.Close
Set AlexCon = Nothing
End Sub

--
VBA Very Junior
 
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
connect excel form to access table sam Excel Discussion (Misc queries) 2 June 30th 09 05:24 PM
How do I connect to access 2007 data from excel? Marilyn Myers Excel Discussion (Misc queries) 3 December 12th 08 04:15 PM
Help with using ADO to connect Excel to Access [email protected] Excel Programming 4 June 29th 06 10:26 AM
connect to access database and run a query in excel VBA Bob Excel Discussion (Misc queries) 0 April 25th 06 08:12 PM
ADO Connect Access gti_jobert[_78_] Excel Programming 5 April 4th 06 01:24 PM


All times are GMT +1. The time now is 10:40 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"