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: 3
Default calling data from access

i have the following code and gives the error "Run-time error: '-2147217900
(80040e14)': String error in 'ProductId ='

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:\Temp\product.mdb"
sSQL = "SELECT Price FROM Products WHERE ProductId = " &
Range("A10").Value
Set oRS = CreateObject("ADODB.Recordset")
oRS.Open sSQL, sConnect, adOpenForwardOnly, adLockReadOnly, adCmdText

If Not oRS.EOF Then
Sheet1.Range("C2").CopyFromRecordset oRS
Else
MsgBox (No data)
End If

oRS.Close
Set oRS = Nothing

End Sub

My db name = product.mdb
table name in my db = products
What i want to do is to call the value in 'price' column from my
'product.mdb' database to an excel sheet. My db columns a

column1 = ProductId
column2 = ProductName
column3 = Price

My excel columns are named as

A1 = ProductId
B1 = ProductName
C1 = Price

For example, when i write ProductId to my A2 cell, it will call that
product's price from the db and put the value to C2 cell.

How can i correct the error?
 
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
calling access data from excel batuhan Excel Discussion (Misc queries) 1 August 18th 06 10:17 AM
Calling a specific version of Access. Derek Anderson Excel Programming 2 June 17th 05 09:00 PM
calling a stored access query from excel vba Travis Excel Programming 1 April 25th 05 09:11 PM
calling an MS Access query from within VBA for Excel Shane Ambry Excel Programming 0 August 18th 04 08:38 AM
Calling Access Program from Excel John Baker Excel Programming 1 April 24th 04 01:20 PM


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