|
-
Jun 22nd, 2006, 08:16 AM
#1
Thread Starter
Addicted Member
[Resolved}how to get combo box value into sql statement?
hi,
I have a sql statement that get's data based on a combo box value and I can't seem to cencatentate it properly. that's what I'm trying to do:
rs.Open "SELECT * FROM tblEmployees Where Proj = sheet1.combo1.value ", CNN, adOpenDynamic, adLockOptimistic
I want to populate one combo box based on the selection of the previous combo box.
any help is appreciated.
waely
Last edited by waely; Jun 22nd, 2006 at 09:46 AM.
-
Jun 22nd, 2006, 08:39 AM
#2
Re: how to get combo box value into sql statement?
That's because you've referenced the combo box from inside the SQL statement, which SQL will expect as a literal string.
What you really need is this:
s.Open "SELECT * FROM tblEmployees Where Proj = " & sheet1.combo1.value, CNN, adOpenDynamic, adLockOptimistic
Unless Proj is a text field... in which case you need this:
s.Open "SELECT * FROM tblEmployees Where Proj = '" & sheet1.combo1.value & "'", CNN, adOpenDynamic, adLockOptimistic
-tg
-
Jun 22nd, 2006, 08:59 AM
#3
Thread Starter
Addicted Member
Re: how to get combo box value into sql statement?
thanks tg. Proj is a column in my database. either method I use I get this error message:
[Microsoft][ODBC Microsoft access driver] Syntax error (missing operator) in query expression 'Proj = MSP22003'.
what is the deal?
thanks
-
Jun 22nd, 2006, 09:47 AM
#4
Thread Starter
Addicted Member
Re: [Resolved}how to get combo box value into sql statement?
I changed the statement to bo
rs.Open "SELECT * FROM tblemployees Where Proj" & " = '" & sheet1.combo1.value & "'", CNN, adOpenDynamic, adLockOptimistic
and that fixed it.
thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|