473,883 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do you use multiple checkboxes to filter a form?

43 New Member
Hey all,

Say I have a form with 10 different checkboxes (named Check1, Check2,...) that are based on the numbers 1-10. The user will select different checkboxes and then click a button (named Update) that will open a split form (named FormUpdate) based on a query. This form needs to be filtered to where the numbers that were checked equal the same numbers of the Control field named "Number".

For instance, the user checks numbers 2, 3, and 6. Is it possible to filter the form so only the records 2, 3, and 6 of the Column "Number" are showing?

Thanks, I've scrounged the internet and my VBA books and can't seem to find any information that is working for me.

-Ben
Jan 25 '12
28 8089
Lynch225
43 New Member
I'm still getting the same run-time error 2464 with the following line highlighted:

Expand|Select|Wrap|Line Numbers
  1. ThisChkbox = Ctrl.Value
I'm using Access 2007 (don't know if this makes a difference). Is there any other verbage I can use?

Also, Check is the name of the form as well. I'm not sure what the option group is for checkboxes, but I'm pretty sure I'm not using them.
Jan 26 '12 #11
C CSR
144 New Member
We've got some other issue. Are you "saving" and then "compiling" the code? If not, make sure you code looks good and click on "Debug" on the menubar, the click "Compile...[your dbname]". If no error, then try the form again.

We may need to check the "References " from inside the Visual Basic window. On the same "Menubar" click on Tools>Reference s. You should at least have checked at the top:

1)"Visual Basic for Applications"

2)"Microsoft Office 12.0 Object Library"

3)"OLE Automation"

4)"Microsoft Office 12.0 Access engine database Object Library"

Another question: I assume you have one form with the checkboxes all by itself, and you want to open a separate SplitForm. Correct?

Let me know. We'll get it fixed--but its not the code. We could rewrite it another way, but we're avoiding an issue that'll come back at you. I'm looking into any special circumstance relating to the "Value" property, as a property, and issues regarding access to that.

Again, It all works here (I'm in Access 2007). Let me know.
Jan 26 '12 #12
C CSR
144 New Member
Not related to above error, but you are missing an "=" sign in the following line:

Expand|Select|Wrap|Line Numbers
  1.     RecsChose = RecsChose & "Trailers_Unloading_LA.Door" & Narr(j) & ";" 
  2.  
  3.  
Put "Door="
Jan 26 '12 #13
Lynch225
43 New Member
Did the above suggestions and am still getting the same error on the same line. Is there a way to use something other than Thischkbox? And yes, you are right about the 2 different forms.
Jan 26 '12 #14
C CSR
144 New Member
There's always a less than pretty method that'll work, but you'll lose flexibility for adding or taking away controls. I'll rethink it. I did some research and the use of the "control.va lue" for checking forms is constantly used for other applications, and it has issues that can usually be resolved. Do a couple of other things while I recompose. We've hacked away on this thing, so clear your mind and first read all of the following and then tediously proceed as follows:

1) Most importantly: Originally you got a [Run-time error 91: "Object variable or With block variable not set"] on the "Ctrl.Value " line. You made a change to [For Each Ctrl In Forms!Check.Con trols] and then you said the error changed to [run-time error 2424: "The expression you entered has a field, control, or property name that Microsoft Access can't find"]. Put the following line in instead of the others and retest:

Expand|Select|Wrap|Line Numbers
  1.  For Each Ctrl In Me.Controls
  2.  
Make sure the "Ctrl" variable is declared (i.e., Dim Ctrl as Control, NOT as Object). [Save, Compile & Test]. NOTE the error message if any for this exact condition.

2) Compact and Repair the Database: Go to the Office Button (top left), click "Manage" and "Compact and Repair." [test code]

3) If we're still broke, Change the name of the Main form (and reassure me that its not a subform of some other form); change it to "Check1" for example (and make sure that no table or query has the same name). The actual name of the form should NOT appear anywhere in the code. [save, compile and test]

4) The Checkbox controls should not be bound to an underlying table: In Form Design View click each check box (not the label), look at its properties sheet, look on the "Data" tab; make sure the "Control Source" line is Blank. [save and test].


5) Lastly, make sure that the "References " you looked up from the module design toolbar are checked, but do NOT say "MISSING."

I'll hack out a work-around for fun. At least that way you can proceed with other design issues. Whew!
Jan 26 '12 #15
Lynch225
43 New Member
Haha even after all those changes/ suggestions, I am still getting the same error on the same line. When I was first looking into doing this, I was experimenting with a code that is similar to this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Update_Click()
  2. Dim Narr() As Variant
  3. Dim i as Integer
  4. Dim ctrl as Control
  5. i = 1
  6. For Each ctrl In Me.Controls
  7.     If Me.("Check" & i) = True Then
  8.           ReDim Preserve Narr(i)
  9.           Narr(i) = ctrl.DefaultValue
  10.           i + 1 = i
  11.     End If
  12. Next
  13.  
  14. If i > 0 Then
  15.     For j = 1 To UBound(Narr) - 1
  16.     RecsChose = RecsChose & "Trailers_Unloading_LA.Door=" & Narr(j) & " OR "
  17.     Next
  18.     RecsChose = RecsChose & "Trailers_Unloading_LA.Door=" & Narr(j) & ";"
  19.     sqlP1 = "SELECT Trailers_Unloading_All.Door, Trailers_Unloading_All.Trailer_Number FROM Trailers_Unloading_All WHERE "
  20.     sqlStr = sqlP1 & RecsChose
  21.     Else
  22.     ErrMess = MsgBox("Nothing Checked", vbOKOnly, "Status")
  23. End If
  24.  
  25. DoCmd.OpenForm "UnloadNow", acNormal, sqlStr
  26.  
This exact code isn't working for me right now, but I was wondering if something similar could be used to loop through the controls.
Jan 26 '12 #16
Lynch225
43 New Member
Oh boy C CSR, I was sitting here banging my head against the table when something hit me to try and redo everything on a new form. As I was doing this, I remember that my original form was for some reason opened as a modal dialog form. Now everything seems to be workimg alright until I get to the actual open form command. Now I am getting a Run-time erro 3464: Data type mismatch in criteria expression with final line highlighted:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "UnloadNow", acNormal, sqlStr, , acFormReadOnly, acWindowNormal
  2.  
Jan 26 '12 #17
Lynch225
43 New Member
The form UnloadNow is a split form based on the query Trailers_Unload ing_LA. If the sql portion of the code, would I have to reference the original tables? Or is that not the issue?

Again forgive my ignorance and sorry for wasting all of your time earlier when you were right with the first code
Jan 26 '12 #18
C CSR
144 New Member
Hey Lynch, I knew the code was good, but what's really fantastic is that you went one last extra step and found the missing configuration monster! Kudo's! You just inherited the Earth.

Now back to work. I was trying to avoid that string loop at all cost because it's just bad practice. Modifications can be a nightmare if you ever have to make them.

I'll look the openform issue and get back to you [tied up]. Again, Congratulations !
Jan 26 '12 #19
Lynch225
43 New Member
Well I got the form to open without an error message (finally) by messing around with the filter part of the open form command. While looking at different references, I didn't see any that included the SELECT portion of the sql statement. I removed some of the code so lines 18-27 of your first code now look like:

Expand|Select|Wrap|Line Numbers
  1. If i > 0 Then
  2.     For j = 1 To UBound(Narr) - 1
  3.         RecsChose = RecsChose & "Door=" & Narr(j) & " OR "
  4.     Next
  5.     RecsChose = RecsChose & "Door=" & Narr(j) & ";"
  6.     sqlStr = RecsChose
  7.     Else
  8.     ErrMess = MsgBox("Nothing Checked", vbOKOnly, "Status")
  9. End If
  10.  
The only issue is that it's not filtering haha. Soo, that's where I'm at now...
Jan 27 '12 #20

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

Similar topics

6
14765
by: jeffsnox | last post by:
Hi, I have multiple checkboxes on the same form as follows: <input type='checkbox' name='cbtype' value='1'> <input type='checkbox' name='cbtype' value='2'> <input type='checkbox' name='cbtype' value='3'> I'm wanting to re-display the same checkboxes, but if the user previously checked one of them then I want it automatically checked on
4
2593
by: ramapv | last post by:
can i highlight a checkbox from a group of checkbox with particular name which is given as a search key. I am having a list of checkboxes and i have to select some of them and form a group.but i'm having a huge list of names , so i want to keep a function so that i can go to (scroll) the name which starts with a particular alphabet & i can check it for selecting components to form a group. both are in different frames. Thanks in...
4
2202
by: favor08 | last post by:
I have a continious subform that 9000 + records and I have serveral check marks on the subform. so it ties to that record. Does anyone have any examples were they use multiple checkboxes in a continous form and how they lined them up. Just looking for an example. Currently I have some to the far left and others to the far right and have them move over based on what option they select.
6
15643
by: dream2rule | last post by:
Hello All, I am trying to validate multiple checkboxes whose values are stored in an array using php. I have been trying from a really long time but nothing's working out. Can anyone help? Here's the code: <form id="create_user" name="create_user" method="post" action="creating_database.php" onsubmit="return validate_create_user_form();">
0
1626
by: serghei | last post by:
I have already the insert form and the database. It's working to insert multiple data with multiple checkboxes. But I can't retrieve multiple data.
0
1648
by: Ned Balzer | last post by:
Hi, Can anyone point me in the direction of a solution for validating multiple checkboxes in an asp.net 2.0 page? 1) This is not a checkboxlist, it is a number of separate checkboxes 2) I do not need to ensure that they are checked, what I am trying to do is lock down the page to prevent possible code injection. So, the checkboxes can be either checked or unchecked, I don't care.
3
2763
by: santoshjsh | last post by:
hello everyone, i have a gridview in which i have multiple checkboxes in a single column. means for every row in the gridview i have four checkboxes in one column e.g Add, Delete, Print, Modify. now i need to bind these check boxes from database table according to the four different fields in the table in which the value is 0 and 1. if the column value is 1 than the checkbox should be displayed checked otherwise no. i dont know how...
3
18307
by: raamay | last post by:
hey experts, please advise me what is the best way to save multiple checkboxes value in a database. I have 6 checkboxes and i came across storing the values in a single column of a table which i dont want to implement as the checkbox values may be used for search purpose in latter stage. Apart from that i also came across creating individual columns for each checkbox which i feel would really make my table large. Is there any other way that i...
0
1388
by: kimmelsd33 | last post by:
I am adding to my software. I have placed about 30 checkboxes on a form. Based on which checkboxes are selected, I want to print the values to a tab delimited text file. For instance, the first checkbox is labeled "Depth" and corresponds to a named variable of 'depth'. If this checkbox is select, I want to print column A, or 'depth' to the file. This part is easy. I am looking for the simplest way to write to a tab delimited text file, if there...
12
2859
by: BabyLucifer666 | last post by:
Hello All, (using Access2000) I have a form with multiple unbound checkboxes. What I would like to do is have the user check whoever needs to take a specific training course. My database is normalized, I have no Yes/no fields in my tables, what I have is VB code that inputs an IDnumber into the field that matches the specific job title for the employee that needs to take that course: Private Sub chkMFGAssoc_Click() If Me.chkMFGAssoc =...
0
9944
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11154
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10863
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9586
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7136
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5807
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4622
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4228
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3241
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.