yes/no hiding records (1 Viewer)

reynier09

Registered User.
Local time
Today, 06:52
Joined
Jul 27, 2017
Messages
12
Hi, i have a form bound to a table. the form has 3 yes/no checkbox and I'm trying to hide certain record if the checkbox is checked. I know that I can query the records, but was wondering whether you can hide unnecessary records(these are records I don't want users to edit, so lock them is also an option) automatically while you check the checkbox? Thanks
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 21:52
Joined
May 7, 2009
Messages
19,246
Ther is Conditiona Formarting where you can change the color of unwanted records.
There is also onCurrent event if the form that you can use to disable edit on the current record.
 

reynier09

Registered User.
Local time
Today, 06:52
Joined
Jul 27, 2017
Messages
12
Actually hiding the record is a bad idea as it might happen by accident.
I have managed to lock it, the only issue is unlocking it within the form.
As far as I have researched I don't think you can lock/unlock by checking/unchecking the text box, hopefully I'm wrong.
Is it possible then to add a button that would reset all the input(unlock)
in case of checking by accident? Thanks
 

reynier09

Registered User.
Local time
Today, 06:52
Joined
Jul 27, 2017
Messages
12
Thanks I got it. I used a button to unlock the desired record with
Me.AllowEdits = True, either way if someone knows how to lock/unlock by checking/unchecking the check box I would like to know. I imagined with VBA you can maybe count the amount of clicks on the check box and assign AllowEdits = True to evens and AllowEdits = False to odds, but I'm a beginner with VBA.
 

plog

Banishment Pending
Local time
Today, 08:52
Joined
May 11, 2011
Messages
11,670
Each time the check box is clicked the computer knows. What you do is you attach code to that event. In that code you determine if the check box is true or false, then hide/unhide accordingly.
 

reynier09

Registered User.
Local time
Today, 06:52
Joined
Jul 27, 2017
Messages
12
Seems easy that way, could you try it and attach a working code. Remember that once it's checked the condition is true and won't allow edits including unchecking, as far as i know and tried.
 

plog

Banishment Pending
Local time
Today, 08:52
Joined
May 11, 2011
Messages
11,670
No, perhaps someone else will give it a go.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 21:52
Joined
May 7, 2009
Messages
19,246
For 3 chkboxes you need to code each chkboxes click event. But first create a "tag" property for the chkboxes,ie. Chk1 tag: "noLock", chk2: "noLock", chk3: "noLock"

Private sun chk1_click()
Dim c as control
If me.chk1 and me.chk2 and me.chk3
For each c in me.controls
If c.tag<>"noLock" and (typeof c is textbox or typeof c is combobox or typeof c checkbox) then
C.locked=true
Else
C.locked=false
End if
End if
End sub

Copy the code to chk2 and chk3 click event
 

Users who are viewing this thread

Top Bottom