471,073 Members | 1,130 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,073 software developers and data experts.

Need to only run a module if the checkbox is checked

9 Byte
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.

Jul 8 '21 #1
8 5459
367 Expert Mod 256MB
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
Jul 8 '21 #2
32,341 Expert Mod 16PB
"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.
Jul 8 '21 #3
9 Byte
Thank you, I added more details. I have ever coded before and have been given a rather large project.
Jul 9 '21 #4
32,341 Expert Mod 16PB
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.
Jul 9 '21 #5
9 Byte
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(tblExhibitsTemplate.ID) AS FirstID, CoSort, AcSort, Ex5Sort"
strSQL = strSQL & " FROM tblExhibitsTemplate"
strSQL = strSQL & " GROUP BY CoSort, AcSort, Ex5Sort"
strSQL = strSQL & " ORDER BY CoSort, AcSort, Ex5Sort;"
Dim rsFirstId As Recordset
Set rsFirstId = MakeRecordSet(strSQL)
With rsFirstId
strSQL = ""
strSQL = strSQL & " UPDATE tblExhibitsTemplate "
strSQL = strSQL & " SET LineNumber = Mid(Str(10000000+[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.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
Loop Until .EOF
End With
Set rsFirstId = Nothing
Jul 9 '21 #6
32,341 Expert Mod 16PB
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.

Jul 12 '21 #7
9 Byte
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.
Jul 14 '21 #8
32,341 Expert Mod 16PB
I'm sorry I got distracted from this. Where are we now? Does your last comment mean you understand now & don't need help?
Aug 9 '21 #9

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Visual Systems AB \(Martin Arvidsson\) | last post: by
3 posts views Thread by nologo | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.