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: 13
Default Run-Time Error 3075

I'm trying query an access database from excel but I'm getting

Run-Time error '3075':

Syntax error (missing operator) in query expression
'(OpLogJobDataID) = & pk'.


in this line og code:


Set rs1 = db.OpenRecordset( _
"select (JobName) from tbl_OperatorLogJobData Where
(OpLogJobDataID) = & pk")

If I replace the line with:


Set rs1 = db.OpenRecordset( _
'"select (JobName) from tbl_OperatorLogJobData Where
(OpLogJobDataID) = 25")

I get no error and the code work.



My full code:



Sub agent()

Dim db As Database, rs1 As Recordset, r As Long, ur As Long
Dim pk As Long


Set db = OpenDatabase("C:\AAAOperatorLog\OperatorLog.mdb")

pk = Range("B100").Value





Set rs1 = db.OpenRecordset( _
"select (JobName) from tbl_OperatorLogJobData Where
(OpLogJobDataID) = & pk")


Range("D2").Value = rs1(0).Value



rs1.Close
Set rs1 = Nothing
db.Close
Set db = Nothing



End Sub

























 
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
run time error 1004 general odbc error excel 2003 vba Mentos Excel Programming 5 January 24th 11 02:56 PM
Error handling error # 1004 Run-time error [email protected] Excel Programming 3 May 20th 08 02:23 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error rdavis7408 Excel Programming 1 August 25th 04 03:54 AM
Code Error - Run Time Error 5 (Disable Cut, Copy & Paste) Tim[_36_] Excel Programming 4 April 23rd 04 02:53 AM


All times are GMT +1. The time now is 10:02 AM.

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"