Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 generating where clause on tick box

Author  Topic 

Pace
Constraint Violating Yak Guru

264 Posts

Posted - 2006-08-10 : 11:07:11
Hi all,

Thanks for reading this, I have a form that loads lots of customer data. We have a different status for each customer... 6

What I want to do is when I load the customers form show six tick box's, 4 will be selected by default the others wont... now I have that bit.

What I need to do is create my WHERE clause to add to my recordsource string.

So I would have "SELECT * FROM Customers WHERE Customer.Status LIKE " & strMyWhere

so I need my where to look like "'A'" as checkbox A is a default. B, C and D would also be a default... so by default it would look something like "'A' OR 'B' OR 'C' OR 'D'" but I also need to be able to add my optional ones and or remove some of the defaults... I just cant work out the correct stucture, mainly because of the "OR" but I also have a feeling there is a better way of doing this...

Does anyone have any ideas? or am I not making much sense?

when life hands you lemons, ask for tequila and salt

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-08-10 : 12:21:51
use a string variable and have that variable to create as per selections

eg.

Dim sCondition as string
sCondition = ""

If Case_E = 1 then
sCondition = " Or E "
End if
If Case_F = 1 then
sCondition = " Or F "
End if

UrQry = "SELECT * FROM Customers WHERE A or B or C or D " & sCondition

if u want a full list of selection, u should have a set of If's as above and the query string should look like

UrQry = "SELECT * FROM Customers WHERE 1 = 0 " & sCondition


Srinika
Go to Top of Page
   

- Advertisement -