Errorcode 3065

kmrowlan

Board Regular
Joined
Aug 5, 2009
Messages
80
Need some help! I'm getting this error:

Run-time error '3065': Cannot execute a select query.

Here is the code:

Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("cmTable", dbOpenDynaset)

Dim strSQL As String
Dim strQuoteID As Long
strQuoteID = Text2
If Nz(Rep.Column(0), 0) = 0 Then
MsgBox "You must Select A Rep"
Exit Sub
Else
End If

strSQL = "SELECT * From cmTable " & _
"WHERE (((cmTable.QuoteID) = 724));"

CurrentDb.Execute strSQL, dbFailOnError
DoCmd.Close acForm, "CopyQuote_Header", acSaveYes

I know it is an issue of data but not sure how to solve it.
Any help would be greatly appreciated! Thanks
 
Well, you definitely have space problems and single quotes where there shouldn't be any (the red is where I found spaces missing between the two items in red) .

Here it is corrected:
Rich (BB code):
strSQL = "INSERT INTO cmTable ( PanelType, Thick, Sqft, [Line], Location, Price, TotalCost, LPrice, NPrice, QuoteID, Mult, Description, TimeFrame) " & _
"SELECT cmTable.PanelType, cmTable.Thick, cmTable.Sqft, cmTable.[Line], cmTable.Location, cmTable.Price, cmTable.TotalCost, cmTable.LPrice, cmTable.NPrice, '" & strNewQuoteID & "', cmTable.Mult, cmTable.Description, cmTable.TimeFrame " & _
"FROM cmTable " & _
"WHERE (((cmTable.QuoteID) Like '*" & strQuoteID & "*'));"
 
Last edited:
Upvote 0

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Make sure "*722*" has quotes on both sides -- your last post has one missing from the right side.
 
Upvote 0
Make sure "*722*" has quotes on both sides -- your last post has one missing from the right side.
??? where are you seeing that?

EDIT: (Never mind, I see where you saw it). There was more to it that just that, just like I said - missing quotes and spaces.
 
Last edited:
Upvote 0
Thank you Bob.
That did it. Sorry to bother you on Syntax.
Should have worked thru that myself.
 
Upvote 0

Forum statistics

Threads
1,215,514
Messages
6,125,267
Members
449,219
Latest member
daynle

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top