468,741 Members | 2,013 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,741 developers. It's quick & easy.

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.

Thanks!
2 Weeks Ago #1
7 3262
isladogs
276 Expert 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
2 Weeks Ago #2
NeoPa
32,129 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.
2 Weeks Ago #3
brittaff
9 Byte
Thank you, I added more details. I have ever coded before and have been given a rather large project.
2 Weeks Ago #4
NeoPa
32,129 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.
2 Weeks Ago #5
brittaff
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
.MoveFirst
Do
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
.MoveNext
Loop Until .EOF
End With
Set rsFirstId = Nothing
2 Weeks Ago #6
NeoPa
32,129 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.

-Ade.
2 Weeks Ago #7
brittaff
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.
1 Week Ago #8

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
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.