By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,107 Members | 1,318 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,107 IT Pros & Developers. It's quick & easy.

Syntax error....

P: 19
I have this code:
Expand|Select|Wrap|Line Numbers
  1. Set rs = db.OpenRecordset("SELECT * FROM expressions order by heb WHERE '" & TextBox2.Text & "' = InStr(![heb], TextBox1.Text)")
Can someone show me where the syntax error is and what is the correct way to write this line?

I am desperate!!! :-(
Feb 17 '09 #1
Share this Question
Share on Google+
5 Replies


Expert Mod 2.5K+
P: 2,545
This post appears to be a duplicate of post 25 of this thread, a thread which is now closed to your satisfaction. Please do not double-post your questions as this wastes the time of the experts involved.

You also provide no clue as to what error you are getting or the context of whatever 'this code' is.

A revised version of your code which may have more of a chance of working is shown below.

Expand|Select|Wrap|Line Numbers
  1. Set rs = db.OpenRecordset("SELECT * FROM expressions WHERE [" & TextBox2.Text & "] = " & InStr(![heb], TextBox1.Text) & " ORDER BY heb;")
I'd be surprised if just getting the syntax right means it will work straight away, however, as it may be OK for syntax and still not mean anything to Access...

-Stewart
Feb 17 '09 #2

P: 19
The code is now working beautifully.... I hope I won't have to eat my hat later on... but it's working for now.

Thank you for your reply.

Iris
Feb 17 '09 #3

NeoPa
Expert Mod 15k+
P: 31,419
Expand|Select|Wrap|Line Numbers
  1. = InStr(![heb], ...
is likely to suffer too, as you have an orphaned bang (!) within your SQL string. This syntax is only valid within a With clause of VBA. Not in SQL.
Feb 17 '09 #4

P: 19
![heb] - to -
instr(heb, '" & TextBox1.Text & "')

so it's OK.

Thank you for your kindness and for your caring.

Have a great day!

Iris
Feb 17 '09 #5

NeoPa
Expert Mod 15k+
P: 31,419
No worries,

and Welcome to Bytes!
Feb 17 '09 #6

Post your reply

Sign in to post your reply or Sign up for a free account.