Need a report checkbox which shows a check from any of 3 table fields

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Lucrecious
    New Member
    • Apr 2012
    • 10

    Need a report checkbox which shows a check from any of 3 table fields

    I have three check boxes in a table which I would like tracked in a report check box showing a check mark if any one of the three fields has a positive value. For arguments sake the three fields in the table can be called: check1, check2 and check3. The report check box will only be clear (no check) if all 3 table check boxes are empty or clear. Is it possible to have this within a report? If not, how can it be handled so that it displays within a report and what logical code is required in the tracking check box?
  • nico5038
    Recognized Expert Specialist
    • Nov 2006
    • 3080

    #2
    Just add a column to a query based on the table like:
    Code:
    select field1, field2, IIF(check1=true or check2=true or check3= true,true,false)
    And use that for the report.
    Getting the idea?

    Nic;o)

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32633

      #3
      Your question is so ambiguous that an appropriate answer is hard to find.

      If you're dealing with boolean fields (True or False values only) then :
      Code:
      SELECT ([Check1] AND [Check2] AND [Check3]) AS [ReportCheck]
      If you are actually referring to numeric fields as part of your question implies, and you really want to check for positive numbers rather than simply checking for True values, then :
      Code:
      SELECT (([Check1] > 0) AND ([Check2] > 0) AND ([Check3] > 0)) AS [ReportCheck]
      Please try to make your questions make clearer sense in future.

      Comment

      • Lucrecious
        New Member
        • Apr 2012
        • 10

        #4
        Sorry, here is an elaboration on the particulars of my request.

        1. I have a table, called DRM
        2. In the table are three checkbox fields called EV1, EV2 and EV3
        3. I need to show whether any of the three are true in a checkbox field in a report as space is limited to print horizontally and I only need to see if any one of the three are true or none are true, meaning false (yes = any one field is checked, or no = none of the fields are checked)
        4. Is there a way to show a new check box field which checks the other three fields in the table and returns a yes or no (checked or not) depending on the values of the table fields as described above?

        Comment

        • Rabbit
          Recognized Expert MVP
          • Jan 2007
          • 12517

          #5
          You can use NeoPa's first method, just change the ANDs to ORs.

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32633

            #6
            Rabbit is right on the money. To illustrate, and include the information you have included now (Good move BTW. Better in the first post generally, but learning is always good) :
            Code:
            SELECT ([EV1] OR [EV2] OR [EV3]) AS [AnyEV]
            FROM   [DRM]

            Comment

            • Lucrecious
              New Member
              • Apr 2012
              • 10

              #7
              I have the code which works given the situation I have in the table as follows:

              Code:
              SELECT IIf(PCBanner='Yes' Or PCColumn='Yes' Or PCColumn='Yes' Or PCFootprints='Yes' Or PCPoster='Yes' Or PCOther='Yes','Yes','No') AS PC
              FROM CRF;
              This works as a query, however, I have been unsuccessful in having this code work as the source for a new field within the report.

              Excuse my ignorance; what is the correct place for this code to work as the source of a new field in the report?

              Or... can the query be the source of a field in the report?

              Almost there...
              Last edited by NeoPa; Apr 24 '12, 11:32 AM. Reason: Added mandatory [CODE] tags for you

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32633

                #8
                Now you're confusing me. This is not consistent with your original question, so it's hard to know which information is accurate.

                If this latest post is accurate then you are dealing with Text values and not Boolean ones as would be expected when using a CheckBox control. You also asked originally for code to check if the values were positive. That's a question that makes little sense when dealing with Booleans, but assuming your grasp of Booleans is slim, as most people's are, then understandable. If the values are 'Yes' or 'No' (Text values) then I can't see how anyone could ask such a question. It's beyond meaningless. Hence, with all this info to go on, the only conclusion I can reach is that you don't seem to know what you're dealing with. Not an easy starting position when setting about trying to answer a question.

                For now though, if you have a working query then I'll leave that with you.

                Originally posted by Lucrecious
                Lucrecious:
                can the query be the source of a field in the report?
                This bit makes sense at least. Yes. You can create a field in your query, just as you have here, and use that field in your report.

                Comment

                • Lucrecious
                  New Member
                  • Apr 2012
                  • 10

                  #9
                  Thanks NeoPa, and so how does one include the field from the query in a report? The query does work, thank you for the sample code which I based the query upon in order to get it to work, however, I don't know how to create the field with the query results as the source.

                  Comment

                  • NeoPa
                    Recognized Expert Moderator MVP
                    • Oct 2006
                    • 32633

                    #10
                    That's just confusing. Is your report bound to the query? Obviously it must be for this to make sense, yet from your question it seems maybe it isn't.

                    If it is, then it's simply like using any other of the fields of the query. If it isn't then you may need to look at this again from scratch, and maybe learn some of the very basics before trying to use Access.

                    Comment

                    • Lucrecious
                      New Member
                      • Apr 2012
                      • 10

                      #11
                      NeoPa, I figured it out, and, thank you.

                      Comment

                      Working...