Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default Get results from Access Database.

Hi All,

I have Excel File & Access Database.

Access Database Contains - Employee details like
Employee ID, Address, Contact No., Process.
Database has more 5000 records.

In Excel I have 200 Employee ID - I need Contact No. & Process.
How can i get this results using ADO connection.

Earlier we use to export access database to excel and then
do VLookup to get the results.

Now we are trying to automate this steps.

I am using like this

Dim DB As ADODB.Connection
Dim RS As ADODB.Recordset

Set DB = New ADODB.Connection

With DB
.Provider = "Microsoft.JET.OLEDB.4.0"
.ConnectionString = "Data Source=" & LOCATION5 & ";" & _
"Jet OLEDB:Database Password=" & PSWD & ";"
.Open
End With

Set RS = New ADODB.Recordset

SQL = "SELECT * FROM EMPLOYEETABLE"
SQL = SQL & " WHERE EMP_ID = " & Sheets(sheet1).Range("A1").value

RS.Open SQL, DB, adOpenDynamic, adLockOptimistic

and it goes like and get the result.
I showed you only if i have one employee id....

Actually I have 200 employee ids in Column A.
If I use Do.... Loop.
Is this will run faster ??

I need to get the data in a faster way.

Please help how can i Achieve this.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 834
Default Get results from Access Database.

Try this

Lastrow = Sheets("Sheet1").Range("A1").End(xlDown).Row
vecLookup =
Application.Transpose(Sheets("Sheet1").Range("A1") .Resize(Lastrow))
Sql = "SELECT * FROM EMPLOYEETABLE"
Sql = Sql & " WHERE EMP_ID IN (" & Join(vecLookup, ",") & ")"


HTH

Bob

"fi.or.jp.de" wrote in message
...

Hi All,

I have Excel File & Access Database.

Access Database Contains - Employee details like
Employee ID, Address, Contact No., Process.
Database has more 5000 records.

In Excel I have 200 Employee ID - I need Contact No. & Process.
How can i get this results using ADO connection.

Earlier we use to export access database to excel and then
do VLookup to get the results.

Now we are trying to automate this steps.

I am using like this

Dim DB As ADODB.Connection
Dim RS As ADODB.Recordset

Set DB = New ADODB.Connection

With DB
.Provider = "Microsoft.JET.OLEDB.4.0"
.ConnectionString = "Data Source=" & LOCATION5 & ";" & _
"Jet OLEDB:Database Password=" & PSWD & ";"
.Open
End With

Set RS = New ADODB.Recordset

SQL = "SELECT * FROM EMPLOYEETABLE"
SQL = SQL & " WHERE EMP_ID = " & Sheets(sheet1).Range("A1").value

RS.Open SQL, DB, adOpenDynamic, adLockOptimistic

and it goes like and get the result.
I showed you only if i have one employee id....

Actually I have 200 employee ids in Column A.
If I use Do.... Loop.
Is this will run faster ??

I need to get the data in a faster way.

Please help how can i Achieve this.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default Get results from Access Database.

Bob simply great....

Thank you.


On Dec 12, 3:57*pm, "Bob Phillips" wrote:
Try this

Lastrow = Sheets("Sheet1").Range("A1").End(xlDown).Row
vecLookup =
Application.Transpose(Sheets("Sheet1").Range("A1") .Resize(Lastrow))
Sql = "SELECT * FROM EMPLOYEETABLE"
Sql = Sql & " WHERE EMP_ID IN (" & Join(vecLookup, ",") & ")"

HTH

Bob

"fi.or.jp.de" *wrote in message

...

Hi All,

I have Excel File & Access Database.

Access Database Contains - Employee details like
Employee ID, Address, Contact No., Process.
Database has more 5000 records.

In Excel I have 200 Employee ID - I need Contact No. & Process.
How can i get this results using ADO connection.

Earlier we use to export access database to excel and then
do VLookup to get the results.

Now we are trying to automate this steps.

I am using like this

Dim DB As ADODB.Connection
Dim RS As ADODB.Recordset

Set DB = New ADODB.Connection

With DB
* * .Provider = "Microsoft.JET.OLEDB.4.0"
* * .ConnectionString = "Data Source=" & LOCATION5 & ";" & _
* * * * "Jet OLEDB:Database Password=" & PSWD & ";"
* * .Open
End With

Set RS = New ADODB.Recordset

SQL = "SELECT * FROM EMPLOYEETABLE"
SQL = SQL & " WHERE EMP_ID = " & Sheets(sheet1).Range("A1").value

RS.Open SQL, DB, adOpenDynamic, adLockOptimistic

and it goes like and get the result.
I showed you only if i have one employee id....

Actually I have 200 employee ids in Column A.
If I use Do.... Loop.
Is this will run faster ??

I need to get the data in a faster way.

Please help how can i Achieve this.


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
Access to Excel: Identify attachment field in access database sam Excel Programming 4 January 7th 10 07:55 PM
Update Excel Database via Access Main Database with a script Finnbar New Users to Excel 2 November 3rd 08 07:24 PM
HELP: VBA Code to extract data from an SQL Server database and put it into Access Database Clinton M James[_2_] Excel Programming 1 October 8th 07 12:44 AM
horseracing results database storage hodgy Setting up and Configuration of Excel 0 February 22nd 06 11:27 AM
help in showing results of database query andy[_6_] Excel Programming 1 August 27th 04 08:47 AM


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