Filtering Question

Brookelyn

The Trying One
Local time
Today, 13:01
Joined
Jan 24, 2006
Messages
14
The following code gives me a syntax error in the INSERT INTO statement. I can't see the problem with it considering it pretty much looks just like my other sql string. Can anyone else see the problem? I'm sure it's right under my nose and I've just been looking at it too long. When I hit debug it highlights the line DoCmd.RunSQL (SQLarchive).

Dim ftrBrand As String
ftrBrand = ""
ftrBrand = InputBox("Enter Brand Name", "Brand Name")


Dim SQLarchive As String

SQLarchive = "INSERT INTO [FilteredTable]" & _
"SELECT [Store Data].*, FROM [Store Data] WHERE [Store Data].Brand = ftrBrand"
DoCmd.RunSQL (SQLarchive)

Thank you
 
Get rid of the comma after [Store Data].* and put a semicolon at the end of the SQL statement.
 
you need to place the variable outside of the string

"SELECT [Store Data].* FROM [Store Data] WHERE [Store Data].Brand = '" & ftrBrand & "'"

HTH

Peter
 
Great that works. Heres the same problem that I had yesterday and I used the same technique here as I did to solve yesterdays problem, but it didn't work. It wants me to enter the parameter value of ftrBrand. ftrBrand should equal the data that is entered into The Inputbox. Can you help me out? P.S. The Brand can have spaces in it.

Thanks a bunch
 
Nevermind my last post
I got it.

Thanks for your help guys! :)
 

Users who are viewing this thread

Back
Top Bottom