Syntax

M

morgan

Hi everyone, I'm trying to build a VB code in order to append a WHERE clause
in a query but I'm just a newbie and I need your help.

Here below the SQL that I want to create:
WHERE (((T_CC_comune.[Data
Valuta])>=Forms!F_CC_comune_ParametriReport!txtdatefrom And
(T_CC_comune.[Data Valuta])<=Forms!F_CC_comune_ParametriReport!txtDateTo) And
((T_CC_comune.[Centro Costo]) Like
Forms!F_CC_comune_ParametriReport!TxtSelect))

I don't know the syntax to add the "AND" part to the following code:
strWhere = " WHERE [Centro Costo] in " & "(" & Left(strIN, Len(strIN) - 1) &
") ....
in which strIN come from the combo box TxtSelect

Thks in advance
 
P

Paolo

Hi Morgan,
I dunno if I understand well your request but If you wanna add
And ((T_CC_comune.[Centro Costo]) Like
Forms!F_CC_comune_ParametriReport!TxtSelect))
to strwhere, assuming Forms!F_CC_comune_ParametriReport!TxtSelect is a text
field, do as follow

strWhere = " WHERE [Centro Costo] in " & Left(strIN, Len(strIN) - 1) &
" And ((T_CC_comune.[Centro Costo]) Like """ &
Forms!F_CC_comune_ParametriReport!TxtSelect)) & """"

I also stripped some unnecessary brackets.

HTH Paolo
 

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