SQL run through VBA run time error

Gregorys05

Board Regular
Joined
Sep 24, 2008
Messages
217
Hi guy's
I am trying to run the below query but keep getting:
___
Run time error 3067
Query input must contain at least one table or query
___

but have no idea why as the query run fine in the query builder but will not run in VBA??

Any ideas

CODE:
Code:
Set QDF = DB.CreateQueryDef("", "INSERT INTO NotePadOutput ( NotepadArea, NotpadGenericcode1, AttributeCode1, NotepadInstruction, NotepadLink, NotepadType )" & _
"SELECT tblimageuploadcheck_1.NotepadArea, Left([Fname],7) AS ASSETID, IIf([notepadarea]='ASSET','',[ATTCODE]) AS AttributeCode1, 'A' AS NotepadInstruction, [FPath] & [FNAME] AS NotepadLink, 'L' AS NotepadType" & _
"FROM (SELECT Files.Fname, Files.FPath, Files.DateCreated, Mid(Files.Fname,IIf(InStr(Files.Fname,'-')=0,1,InStr(Files.Fname,'-'))+1,IIf(InStr(Files.Fname,'.')=0,1,InStr(Files.Fname,'.'))-IIf(InStr(Files.Fname,'-')=0,1,InStr(Files.Fname,'-'))-1) as ShortFname" & _
"FROM Files). AS tblFormattedFileSNotepad INNER JOIN tblimageuploadcheck AS tblimageuploadcheck_1 ON tblFormattedFileSNotepad.ShortFname = tblimageuploadcheck_1.Code" & _
"WHERE (((tblimageuploadcheck_1.NotepadArea)='ASSET'));")
QDF.Execute

Thanks
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Just a quick look at the code. it seems you have no spaces between your lines

For example: (and there may be others)
Code:
 .......
INNER JOIN tblimageuploadcheck AS tblimageuploadcheck_1 ON tblFormattedFileSNotepad.ShortFname = tblimageuploadcheck_1.Code" & _
"WHERE (((tblimageuploadcheck_1.NotepadArea)='ASSET'));")

There is NO SPACE between
tblimageuploadcheck_1.Code" and WHERE
 
Upvote 0

Forum statistics

Threads
1,224,579
Messages
6,179,656
Members
452,934
Latest member
mm1t1

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