Good afternoon,
I would like to know if anyone can direct me as to how I can write a VBA code to deselect about 26 check boxes, for all records.
I have been searching the internet, but I haven't came across anything.
Right now I have a command button on the form, that is able to deselect one checkbox for a single record. I don't want to have to hard code in all the checkboxes names into VBA.
Thanks
18 2706 Rabbit 12,516
Recognized Expert Moderator MVP - Dim Ctl As Control
-
For Each Ctl In Me.Controls
-
If Ctl.Properties("ControlType") = acCheckBox Then Ctl = False
-
Next Ctl
-
Thank you so much. Now the only problem is that it work for 1 out of 22 records. For each row (record), there are about 22 check boxes, so in actuality, I need to clear about 400 check boxes. - Dim Ctl As Control
-
For Each Ctl In Me.Controls
-
If Ctl.Properties("ControlType") = acCheckBox Then Ctl = False
-
Next Ctl
-
Rabbit 12,516
Recognized Expert Moderator MVP
For ease of implementation, put the code in the On Current event of the form. Change the form to continous form view. Then open the form. You can change it back after.
Ok I did as you suggested. When the I switched it to form view, only the first row deselected. All the other rows remained the same.
For ease of implementation, put the code in the On Current event of the form. Change the form to continous form view. Then open the form. You can change it back after.
I just tested using the move next record button, and once I did that, it deslected each row as it appeared. I guess I need to have a movenext function in there?
Ok I did as you suggested. When the I switched it to form view, only the first row deselected. All the other rows remained the same.
Rabbit 12,516
Recognized Expert Moderator MVP
Are you sure you set the Default View to Continous Form?
it was already set to that.
Are you sure you set the Default View to Continous Form?
Rabbit 12,516
Recognized Expert Moderator MVP
Odd, it should work. I just tested it and it works. Not an exact replica of what you have but something similar.
Post your code along with the Event Statements.
There aren't really any event statements. It just the deselect button that I am not using. All my records return true/false statements back to a table.
Here is the code:
Private Sub Form_Current()
Dim chk As CheckBox
Dim Ctl As Control
For Each Ctl In Me.Controls
If Ctl.Properties("ControlType") = acCheckBox Then Ctl = False
Next Ctl
End Sub
Odd, it should work. I just tested it and it works. Not an exact replica of what you have but something similar.
Post your code along with the Event Statements.
Rabbit 12,516
Recognized Expert Moderator MVP
Try this: - Private Sub Form_Load()
-
-
Dim Ctl As Control
-
Dim i As Integer
-
-
For i = 1 to Me.RecordSet.Count
-
For Each Ctl In Me.Controls
-
If Ctl.Properties("ControlType") = acCheckBox Then Ctl = False
-
Next Ctl
-
DoCmd.GoToRecord ,, acNext
-
i = i + 1
-
Next i
-
-
End Sub
I am getting an error with the .Count propert. It says the object doesn't support that property.
Try this: - Private Sub Form_Load()
-
-
Dim Ctl As Control
-
Dim i As Integer
-
-
For i = 1 to Me.RecordSet.Count
-
For Each Ctl In Me.Controls
-
If Ctl.Properties("ControlType") = acCheckBox Then Ctl = False
-
Next Ctl
-
DoCmd.GoToRecord ,, acNext
-
i = i + 1
-
Next i
-
-
End Sub
Rabbit 12,516
Recognized Expert Moderator MVP
I am getting an error with the .Count propert. It says the object doesn't support that property.
Guess we'll have to use a clone: - Private Sub Form_Load()
-
-
Dim Ctl As Control
-
Dim i As Integer
-
Dim Rst As RecordSet
-
-
Set Rst = Me.RecordsetClone
-
For i = 1 to Rst.Count
-
For Each Ctl In Me.Controls
-
If Ctl.Properties("ControlType") = acCheckBox Then Ctl = False
-
Next Ctl
-
DoCmd.GoToRecord ,, acNext
-
i = i + 1
-
Next i
-
-
End Sub
I got it working. Instead of using the recordset.count, I used Me.controls.count!
I am getting an error with the .Count propert. It says the object doesn't support that property.
The only problem with this, it that it is moving next about 10 records instead of stopping at the last checkbox.
I got it working. Instead of using the recordset.count, I used Me.controls.count!
Rabbit 12,516
Recognized Expert Moderator MVP
The only problem with this, it that it is moving next about 10 records instead of stopping at the last checkbox.
Use the code from post 13 instead
I tried using that also,
I got an error on the RecordsetClone.
Use the code from post 13 instead
Rabbit 12,516
Recognized Expert Moderator MVP - Private Sub Form_Load()
-
-
Dim Ctl As Control
-
Dim i As Integer
-
Dim Rst As RecordSet
-
-
Set Rst = CurrentDb.OpenRecordset("[Table Name]")
-
For i = 1 to Rst.Count
-
For Each Ctl In Me.Controls
-
If Ctl.Properties("ControlType") = acCheckBox Then Ctl = False
-
Next Ctl
-
DoCmd.GoToRecord ,, acNext
-
i = i + 1
-
Next i
-
-
End Sub
Rabbit 12,516
Recognized Expert Moderator MVP
Ooops, my bad. I forgot it's not .Count, it's .RecordCount
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Orchid |
last post by:
I have 2 fields with Radio button Data Type, and both fields with more
than one options. On Field1, I want the user to select option1, then
Field2 is shown and able to select. If the user selects...
|
by: moondaddy |
last post by:
There are different times when I will have a group of checkboxes and need to
force only one to be checked at a time. I would also like to do this client
side and not require a postback. These...
|
by: GJP |
last post by:
Hello.
I have two list boxes. One with a picture name, and one for the ID of that
picture (both coming from a database).
The user selects the name of the picture and presses a button, the...
|
by: Heck |
last post by:
Hi everyone.
I have created a simple table called "ReceptionTable" to input all materials coming to a drilling rig. I have included in this table a yes/no field (check box) that is selected from a...
|
by: birwin |
last post by:
I found a Javascript snippet that very effectively checks all boxes on a page, even on a page on which the input tags are in tables and on which I use a lot of other javascript. Unfortunately it is...
| |
by: Bailu |
last post by:
Hi,
I am a newbie in wxPython and doing a program with ListBox,
I want to select and deselect items in this box,
I have use
self.devlist = wx.ListBox(self, style=wx.LB_MULTIPLE)...
|
by: zacks |
last post by:
I am having a strange issue with an application written in .NET 2.0.
Actually it is in VB.NET but I think my problem is not language
specific, but a .NET Framework issue.
On a form I have a...
|
by: student4lifer |
last post by:
I thought the group check boxes would be parsed as an array, but the
code below didn't print out as I expected. Could someone explain what
I am missing? Thanks.
==========
<html>
<body>...
|
by: beacon |
last post by:
Hi everybody,
I have a form that has a combo box that asks the user to select the program they work on. Once the user selects the program, a SQL statement populates the row source for 4 staff...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |