Need to only run a module if the checkbox is checked

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • brittaff
    New Member
    • Jul 2021
    • 9

    Need to only run a module if the checkbox is checked

    Sorry for lack of details, this is very new to me.

    I have a large dataset. There is a table that has a column with the checkbox option. The table is created in the module's code. Some options in the table are selected with the checkbox and some are not. I want the records that are selected (checked) to be processed. My module runs on all the data in the set, but I want it to only run for the sets with the boxes checked. The key is figuring out how to filter the data so that only records with the check box checked for their area will be processed. The module is complex and I need to figure out how to filter what is processed.

    Thanks!
    Last edited by brittaff; Jul 9 '21, 12:44 PM. Reason: More details
  • isladogs
    Recognized Expert Moderator Contributor
    • Jul 2007
    • 479

    #2
    Welcome to the forum.
    Whilst I'm sure that all makes sense to you, its not clear exactly what you are asking.
    The BuildExhibit module may well be complex but apart from its name we know nothing about it.

    Assuming you are referring to a field called Included then set a filter in your code/query for Included =True

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32645

      #3
      "Records that are included", "all the data", "the included box", "their area". All of these use real words yet none of them is explained in the context of your work or situation. IE. They're meaningless to anyone but you.

      Please try to rewrite your question so it means something to the reader. That way we have a chance of helping you - and that's what we're here for and want to do.

      Comment

      • brittaff
        New Member
        • Jul 2021
        • 9

        #4
        Thank you, I added more details. I have ever coded before and have been given a rather large project.

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32645

          #5
          Hi Brittaff.

          That makes a little more sense. It's a bit garbled still to be fair but some of it's clearer at least and we do understand that knowing what to include is something you understand better with experience.

          Now, I have to assume that somewhere in your code you open a Recordset object that's based on the table where the data is that you've described. This may be done passing a QueryDef object name or some SQL. Either way, to get a filtered set you'd need to include filtering. If you're using a QueryDef (Saved Query Object) then you need to ensure the QueryDef includes the Field which has a CheckBox and either True or <>False in the Criteria part. On the other hand if it's a SQL string then it must include a WHERE clause that specifies that Field not being False.

          I hope this makes sense. We're still working in a large vacuum here as the items we need to talk about still don't have names. It's never as easy to understand what people are trying to tell you when the names aren't available.

          If you're still struggling then I suggest you identify, and post for us, the line in your code where the Recordset that the code processes is opened. That will be very helpful as it has to include the names of the relevant objects. Names we need as much as VBA does in order to understand what you want.

          Comment

          • brittaff
            New Member
            • Jul 2021
            • 9

            #6
            Here is the first area where the RecordSet function is used:

            'Add "Statement" Line Numbers to table. (line numbers are not correct for Reinsurance Ceded line).
            strSQL = ""
            strSQL = strSQL & " SELECT Min(tblExhibits Template.ID) AS FirstID, CoSort, AcSort, Ex5Sort"
            strSQL = strSQL & " FROM tblExhibitsTemp late"
            strSQL = strSQL & " GROUP BY CoSort, AcSort, Ex5Sort"
            strSQL = strSQL & " ORDER BY CoSort, AcSort, Ex5Sort;"
            Dim rsFirstId As Recordset
            Set rsFirstId = MakeRecordSet(s trSQL)
            With rsFirstId
            .MoveFirst
            Do
            strSQL = ""
            strSQL = strSQL & " UPDATE tblExhibitsTemp late "
            strSQL = strSQL & " SET LineNumber = Mid(Str(1000000 0+[Ex5Sort]*100000+([ID]- " & Str(!FirstId) & " +1)),3,7)"
            strSQL = strSQL & " WHERE (CoSort=" & Str(!CoSort) & ")"
            strSQL = strSQL & " AND (AcSort=" & Str(!AcSort) & ")"
            strSQL = strSQL & " AND (Ex5Sort)=" & Str(!Ex5Sort) & ""
            strSQL = strSQL & " ;"
            DoCmd.SetWarnin gs False
            DoCmd.RunSQL strSQL
            DoCmd.SetWarnin gs True
            .MoveNext
            Loop Until .EOF
            End With
            Set rsFirstId = Nothing

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32645

              #7
              Hi Britaff.

              I'm not ignoring this, nor have I disappeared (except for the weekend where I was away at a wedding) so just to let you know I'll look at this again soon.

              -Ade.

              Comment

              • brittaff
                New Member
                • Jul 2021
                • 9

                #8
                Thanks Ade,

                I have set up a query that runs through the table with the checkboxes and only prints a table with the items checked. My next step is to run another prewritten module for the table that was created from the query.

                Comment

                • NeoPa
                  Recognized Expert Moderator MVP
                  • Oct 2006
                  • 32645

                  #9
                  I'm sorry I got distracted from this. Where are we now? Does your last comment mean you understand now & don't need help?

                  Comment

                  Working...