Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2003
    Location
    Stockholm, Sweden
    Posts
    2

    Unanswered: Check boxes and reports

    Hi All!

    I have written a litterature database (in Acess 2000) covering research about alcohol- and drugrelated problems.

    Now I want end users to be able to select records in the database by clicking on of several check-boxes (each representing a special symtom or problemarea) having a report from that choise.

    How in all the world can I write code so that my application will accept
    single - or multiple - search criteria from checked boxes.

    I am so thankful for all tips I can get.

    Thanks.

    / Anders

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Lightbulb

    If your checkBoxes on a for called F_Start and they are called chk_1, chk_2, .... then on your report you can make IFs or SELECT statements

    For example:
    IF FORMS("F_Start").chk_1 and FORMS("F_Start").chk_2 then
    what 2 do if both are checked

    elseif FORMS("F_Start").chk_1 and FORMS("F_Start").chk_2=False then
    waht 2 do if 1 is checked and 2 is not

    elseif FORMS("F_Start").chk_1=false and FORMS("F_Start").chk_2 then
    waht 2 do if 2 is checked and 1 is not

    elseif NOT FORMS("F_Start").chk_1 AND NOT FORMS("F_Start").chk_2 then

    waht 2 do if both are not checked

    ' or Simply ELSE

    endif


    Hope that what you need

  3. #3
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    if you have many optional things, the only sane way to do it is by constructing some SQL.

    dim strSQL as string
    strSQL = "SELECT * FROM myTable WHERE 1=1" 'thanks rudy!

    if chkbox1 then
    strSQL = strSQL & " AND [whatever] = true"
    endif

    if not isnull(thisTextBox) then
    strSQL = strSQL & " AND [something] ='" & thisTextBox & "'"
    endif

    if not isnull(thatCombo) then
    strSQL = strSQL & " AND [that] = thatCombo"
    endif

    'and so on for each optional thing
    'don't forget the space before each AND
    '
    '

    strSQL = strSQL & " ORDER BY [this];"

    izy
    currently using SS 2008R2

  4. #4
    Join Date
    Nov 2003
    Location
    Stockholm, Sweden
    Posts
    2

    Tricky problems with checkboxes

    OK and thanks!

    I partly understand your code but I need clarifications, if you don’t mind:

    Say I have three checkboxes on a form (representing/describing three symptoms).

    I have a query representing those three checboxes and then additional fields/variables (Cause1,Cause2 …CauseX … etc).

    I want the user to check any combination of the checkboxes on the form and get a report of possible combination of causes to the described symptoms (i.e.combination of checkboxes).

    So how do I apply your code to this problem and where do I put it – do I activate “report” and then “code” and put the result in there? OR ?

    YES - I am a newbie.....

    Anyway - your code is below….would it be possible for you to apply it more to my problem above..

    If not – I am thankful for what you already gave me.

    All the best/
    Anders

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •