criteria on select statment

S

salmonella

Simple question (but not for me). if I have the following select string:

Dim fsuper As Variant
Set fsuper = Forms!pw_temp_form!super

str = "select * from rwop_memo_all where active = 'yes' and supervisor = " &
“ ‘ “ & fsuper & “ ‘ “

How do I add another criterion to this string with a variable like I did for
supervisor? Adding for example……. field2 = " & “ ‘ “ & variant2 & “ ‘ “

thanks
 
R

Roger Carlson

Unless I'm missing something, it would be:

str = "select * from rwop_memo_all where active = 'yes' and supervisor = " &
" ' " & fsuper & " ' and field2 = " & " ' " & variant2 & " ' "

Now, this assumes that Field2 is a text field. If Field2 is a numeric
field, it would be:

str = "select * from rwop_memo_all where active = 'yes' and supervisor = " &
" ' " & fsuper & " ' and field2 = " & variant2

Or if Field2 is a date:

str = "select * from rwop_memo_all where active = 'yes' and supervisor = " &
" ' " & fsuper & " ' and field2 = " & " # " & variant2 & " # "

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
S

salmonella

Roger,
MANY thanks!
I see where i made the mistake and it is working great now.

Thanks again for all the help!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top