View Full Version : [SOLVED:] 1 click ticks 4 rows
Marcster
02-11-2016, 05:22 AM
Hi People,
On a form I have datasheet, on this datasheet there is also a column of checkbox's (data type Yes/No).
There are 4 rows for each 'record', when I click any of the checkbox's it should place a tick in all rows in the 'record' in this column of checkbox's (data type Yes/No).
Also, if I uncheck the box, all rows uncheck.
Column P has the unique identifier that shows what rows belong to what record.They are grouped together, i.e. ordered list.
So each tick I place in a check box, 4 rows should be ticked, based on the value in Column P.
It will always be 4 rows, as the unique value in column P is repeated for each 4 rows.
Thanks,
Use a update query.
currentdb.execute "update YourTable set SomeField = " & CheckBoxValue & " where ColumnP = " & ColumnP
me.requery
Marcster
02-11-2016, 09:35 AM
Thanks jonh.
But not quite what I was after.
If I open Table1 and click any Tickbox in first column then any same ColumnP rows should also be ticked. All 4 rows.
i.e. if I click on the first checkbox, row 1, I want the first 4 checkboxes to be ticked. Row 1,2,3 and 4. As they all have the same ColumnP value.
Field1
ColumnP
<Checkbox>
AAAA
<Checkbox>
AAAA
<Checkbox>
AAAA
<Checkbox>
AAAA
<Checkbox>
BBBB
<Checkbox>
BBBB
<Checkbox>
BBBB
<Checkbox>
BBBB
<Checkbox>
CCCC
<Checkbox>
CCCC
<Checkbox>
CCCC
<Checkbox>
CCCC
If I tick the last row, then the bottom 4 rows should also tick.
These 'ticking'/'un-ticking' can happen on any row in Table1.
Thanks,
... and an update query doesn't solve the problem because ...
Maybe because your checkbox is unbound? But then all checkboxes show the same value so that wont work.
I don't know.
Marcster
02-12-2016, 04:55 AM
Getting the error:
Run-time error '3601':
Too few parameters. Expected 1.
In code:
Dim CheckBoxValue As Boolean
Dim ColumnPValue As String
CheckBoxValue = Forms!Form1!Field1
ColumnPValue = Forms!Form1!ColumnP
CurrentDb.Execute "update Table1 set Field1 = " & CheckBoxValue & " where ColumnP = " & ColumnPValue
Me.Requery
Any idea's?....
That means a field doesn't exist.
Text fields need quotes around the values.
for example
ColumnPValue = "foobar"
"ColumnP = " & ColumnPValue
translates to "ColumnP = foobar"
since foobar doesn't have quotes and isn't numeric it's seen as a field that doesn't exist.
so if columnp is text it should be
"ColumnP = '" & ColumnPValue & "'"
Marcster
02-12-2016, 08:43 AM
Cheers jonh, that's it.
CurrentDb.Execute "update Table1 set Field1 = " & CheckBoxValue & " where ColumnP = '" & ColumnPValue & "'"
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.