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

I have an access db with columns for example "name", "surname", "date of
birth" and "place of birth". And I have an empty worksheet in excel with the
same columns:

column1 = id number
column2 = name
column3 = surname
column4 = date of birth
column5 = place of birth

Now, is it possible to call the data by some type of "id" or something that
for example when i enter "3" in excel sheet column1, it will automatically
fill the other columns by taking data from my access db (person numbered 3 in
access db) ?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default calling access data from excel

Sub GetData()
Const adOpenForwardOnly As Long = 0
Const adLockReadOnly As Long = 1
Const adCmdText As Long = 1
Dim oRS As Object
Dim sConnect As String
Dim sSQL As String
Dim ary

sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & "c:\bob.mdb"

sSQL = "SELECT * From Contacts WHERE Person_Id = " & Range("A1").Value
Set oRS = CreateObject("ADODB.Recordset")
oRS.Open sSQL, sConnect, adOpenForwardOnly, _
adLockReadOnly, adCmdText

' Check to make sure we received data.
If Not oRS.EOF Then
Sheet1.Range("A6").CopyFromRecordset oRS
Else
MsgBox "No records returned.", vbCritical
End If

oRS.Close
Set oRS = Nothing
End Sub



You will need to adapt the database name and SQL and ranges to suit.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"batuhan" wrote in message
...
I have an access db with columns for example "name", "surname", "date of
birth" and "place of birth". And I have an empty worksheet in excel with

the
same columns:

column1 = id number
column2 = name
column3 = surname
column4 = date of birth
column5 = place of birth

Now, is it possible to call the data by some type of "id" or something

that
for example when i enter "3" in excel sheet column1, it will automatically
fill the other columns by taking data from my access db (person numbered 3

in
access db) ?



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
Exporting data in Excel permanently to Access WDR Links and Linking in Excel 1 January 12th 06 03:56 AM
Data from Excel to Access Table Secret Squirrel Excel Discussion (Misc queries) 11 December 2nd 05 11:58 PM
How to import data from a password protected Access DB into Excel. Agus Excel Discussion (Misc queries) 0 October 12th 05 05:42 PM
New Excel data does not appear in linked Access table JohnL Excel Discussion (Misc queries) 0 October 7th 05 04:31 PM
MS Excel data reading in MS Access Paul Excel Discussion (Misc queries) 1 January 27th 05 11:58 AM


All times are GMT +1. The time now is 11:53 PM.

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"