PC Review


Reply
Thread Tools Rate Thread

disallow state change of check box

 
 
alekm
Guest
Posts: n/a
 
      14th May 2010
Hi,
if the check box is clicked how can I disallow change of its state based on
certain terms...
Thanx

alekmil
 
Reply With Quote
 
 
 
 
Stuart McCall
Guest
Posts: n/a
 
      14th May 2010
"alekm" <(E-Mail Removed)> wrote in message
news:F93CDF14-4896-46CE-9FB5-(E-Mail Removed)...
> Hi,
> if the check box is clicked how can I disallow change of its state based
> on
> certain terms...
> Thanx
>
> alekmil


If <certain terms> Then
Checkbox.Enabled = False
Else
Checkbox.Enabled = True
End If

It's best to do this before the checkbox is clicked (say the lostfocus event
of the previous control or something like that)



 
Reply With Quote
 
alekm
Guest
Posts: n/a
 
      14th May 2010
How do I know what control is previos????

"Stuart McCall" wrote:

> "alekm" <(E-Mail Removed)> wrote in message
> news:F93CDF14-4896-46CE-9FB5-(E-Mail Removed)...
> > Hi,
> > if the check box is clicked how can I disallow change of its state based
> > on
> > certain terms...
> > Thanx
> >
> > alekmil

>
> If <certain terms> Then
> Checkbox.Enabled = False
> Else
> Checkbox.Enabled = True
> End If
>
> It's best to do this before the checkbox is clicked (say the lostfocus event
> of the previous control or something like that)
>
>
>
> .
>

 
Reply With Quote
 
alekm
Guest
Posts: n/a
 
      14th May 2010
And I'm looking to disallow change of a check box state not to set it based
on certain terms

"Stuart McCall" wrote:

> "alekm" <(E-Mail Removed)> wrote in message
> news:F93CDF14-4896-46CE-9FB5-(E-Mail Removed)...
> > Hi,
> > if the check box is clicked how can I disallow change of its state based
> > on
> > certain terms...
> > Thanx
> >
> > alekmil

>
> If <certain terms> Then
> Checkbox.Enabled = False
> Else
> Checkbox.Enabled = True
> End If
>
> It's best to do this before the checkbox is clicked (say the lostfocus event
> of the previous control or something like that)
>
>
>
> .
>

 
Reply With Quote
 
Jon Lewis
Guest
Posts: n/a
 
      14th May 2010
That's exactly what Enabled does. If .Enabled = True the check box is
greyed out and you can't change it.

If the context is a single form view Form then use the Current Event for the
code

> If <certain terms> Then
> Checkbox.Enabled = False
> Else
> Checkbox.Enabled = True
> End If


If the conditions change (e.g. you update another control) use the relevent
After Update event to set the Enabled state of the Check Box.

HTH


"alekm" <(E-Mail Removed)> wrote in message
news:531544A2-58EF-433A-8B8A-(E-Mail Removed)...
> And I'm looking to disallow change of a check box state not to set it
> based
> on certain terms
>
> "Stuart McCall" wrote:
>
>> "alekm" <(E-Mail Removed)> wrote in message
>> news:F93CDF14-4896-46CE-9FB5-(E-Mail Removed)...
>> > Hi,
>> > if the check box is clicked how can I disallow change of its state
>> > based
>> > on
>> > certain terms...
>> > Thanx
>> >
>> > alekmil

>>
>> If <certain terms> Then
>> Checkbox.Enabled = False
>> Else
>> Checkbox.Enabled = True
>> End If
>>
>> It's best to do this before the checkbox is clicked (say the lostfocus
>> event
>> of the previous control or something like that)
>>
>>
>>
>> .
>>



 
Reply With Quote
 
alekm
Guest
Posts: n/a
 
      14th May 2010
I don't want to disable check box because there are users allowed to change
it. There are user who are not to allowed to change its state . I want to
check them in before update event and if user is not allowed changing check
box I want to put there Cancel = true.
The questio is: As soon Cancel = true is executed I fall in loop. Event
procedure is execute over and over again. Why is that?

"Jon Lewis" wrote:

> That's exactly what Enabled does. If .Enabled = True the check box is
> greyed out and you can't change it.
>
> If the context is a single form view Form then use the Current Event for the
> code
>
> > If <certain terms> Then
> > Checkbox.Enabled = False
> > Else
> > Checkbox.Enabled = True
> > End If

>
> If the conditions change (e.g. you update another control) use the relevent
> After Update event to set the Enabled state of the Check Box.
>
> HTH
>
>
> "alekm" <(E-Mail Removed)> wrote in message
> news:531544A2-58EF-433A-8B8A-(E-Mail Removed)...
> > And I'm looking to disallow change of a check box state not to set it
> > based
> > on certain terms
> >
> > "Stuart McCall" wrote:
> >
> >> "alekm" <(E-Mail Removed)> wrote in message
> >> news:F93CDF14-4896-46CE-9FB5-(E-Mail Removed)...
> >> > Hi,
> >> > if the check box is clicked how can I disallow change of its state
> >> > based
> >> > on
> >> > certain terms...
> >> > Thanx
> >> >
> >> > alekmil
> >>
> >> If <certain terms> Then
> >> Checkbox.Enabled = False
> >> Else
> >> Checkbox.Enabled = True
> >> End If
> >>
> >> It's best to do this before the checkbox is clicked (say the lostfocus
> >> event
> >> of the previous control or something like that)
> >>
> >>
> >>
> >> .
> >>

>
>
> .
>

 
Reply With Quote
 
Jon Lewis
Guest
Posts: n/a
 
      14th May 2010
I think this is the nature of a CheckBox in that the act of getting focus
changes it so BeforeUpdate kicks in whilst the box still has the focus.
Cancel = True then resets it this triggers another BeforeUpdate event as
soon as focus goes to another control control and so-on.

So basically you can't use Before Update for this.

But do I gather that my previous suggestion won't work because you are
sharing the same 'front end' with multi-users? This isn't a good idea. You
should split the database into a data file that you share and a separate
front end for each user.
If you really don't want to do this then try the Mouse Down event

If <Your Terms> Then
MsgBox "You can't change this "
Me.Checkbox.Locked = True
Else
Me.Checkbox.Locked = False
End If

(You can't disable it as it has the focus)

HTH

"alekm" <(E-Mail Removed)> wrote in message
news:1EBC1586-8141-45CE-9BB9-D6E2 (E-Mail Removed)...
>I don't want to disable check box because there are users allowed to change
> it. There are user who are not to allowed to change its state . I want to
> check them in before update event and if user is not allowed changing
> check
> box I want to put there Cancel = true.
> The questio is: As soon Cancel = true is executed I fall in loop. Event
> procedure is execute over and over again. Why is that?
>
> "Jon Lewis" wrote:
>
>> That's exactly what Enabled does. If .Enabled = True the check box is
>> greyed out and you can't change it.
>>
>> If the context is a single form view Form then use the Current Event for
>> the
>> code
>>
>> > If <certain terms> Then
>> > Checkbox.Enabled = False
>> > Else
>> > Checkbox.Enabled = True
>> > End If

>>
>> If the conditions change (e.g. you update another control) use the
>> relevent
>> After Update event to set the Enabled state of the Check Box.
>>
>> HTH
>>
>>
>> "alekm" <(E-Mail Removed)> wrote in message
>> news:531544A2-58EF-433A-8B8A-(E-Mail Removed)...
>> > And I'm looking to disallow change of a check box state not to set it
>> > based
>> > on certain terms
>> >
>> > "Stuart McCall" wrote:
>> >
>> >> "alekm" <(E-Mail Removed)> wrote in message
>> >> news:F93CDF14-4896-46CE-9FB5-(E-Mail Removed)...
>> >> > Hi,
>> >> > if the check box is clicked how can I disallow change of its state
>> >> > based
>> >> > on
>> >> > certain terms...
>> >> > Thanx
>> >> >
>> >> > alekmil
>> >>
>> >> If <certain terms> Then
>> >> Checkbox.Enabled = False
>> >> Else
>> >> Checkbox.Enabled = True
>> >> End If
>> >>
>> >> It's best to do this before the checkbox is clicked (say the lostfocus
>> >> event
>> >> of the previous control or something like that)
>> >>
>> >>
>> >>
>> >> .
>> >>

>>
>>
>> .
>>



 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      14th May 2010
"Jon Lewis" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I think this is the nature of a CheckBox in that the act of getting focus
>changes it so BeforeUpdate kicks in whilst the box still has the focus.
>Cancel = True then resets it this triggers another BeforeUpdate event as
>soon as focus goes to another control control and so-on.
>
> So basically you can't use Before Update for this.


Yes, you can, but you have to undo the control's update as well as
cancelling it:

Private Sub chkYourCheckbox_BeforeUpdate(Cancel As Integer)

If <some condition> Then
Cancel = True
Me.chkYourCheckbox.Undo
End If

End Sub

I agree with you, Jon, that it doesn't make sense to even to enable the
check box if the user isn't allowed to check it. Your proposal to enable or
disable the check box in the form's Open event, after checking the current
user's authorization, makes perfect sense, and should work regardless of
whether the database is split or not.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

 
Reply With Quote
 
Jon Lewis
Guest
Posts: n/a
 
      14th May 2010
Yes you're right about that of course Dirk, but yes the disabling approach
is much better.

Jon



"Dirk Goldgar" <(E-Mail Removed)> wrote in message
news:0336A8E2-A860-4E11-99E3-(E-Mail Removed)...
> "Jon Lewis" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>I think this is the nature of a CheckBox in that the act of getting focus
>>changes it so BeforeUpdate kicks in whilst the box still has the focus.
>>Cancel = True then resets it this triggers another BeforeUpdate event as
>>soon as focus goes to another control control and so-on.
>>
>> So basically you can't use Before Update for this.

>
> Yes, you can, but you have to undo the control's update as well as
> cancelling it:
>
> Private Sub chkYourCheckbox_BeforeUpdate(Cancel As Integer)
>
> If <some condition> Then
> Cancel = True
> Me.chkYourCheckbox.Undo
> End If
>
> End Sub
>
> I agree with you, Jon, that it doesn't make sense to even to enable the
> check box if the user isn't allowed to check it. Your proposal to enable
> or disable the check box in the form's Open event, after checking the
> current user's authorization, makes perfect sense, and should work
> regardless of whether the database is split or not.
>
> --
> Dirk Goldgar, MS Access MVP
> Access tips: www.datagnostics.com/tips.html
>
> (please reply to the newsgroup)
>



 
Reply With Quote
 
Amy E. Baggott
Guest
Posts: n/a
 
      14th May 2010
You could also disable it in the form's On Open or On Current event based on
the username.
--
Amy E. Baggott

"I''m going crazy and I''m taking all of you with me!" -- Linda Grayson


"Jon Lewis" wrote:

> Yes you're right about that of course Dirk, but yes the disabling approach
> is much better.
>
> Jon
>
>
>
> "Dirk Goldgar" <(E-Mail Removed)> wrote in message
> news:0336A8E2-A860-4E11-99E3-(E-Mail Removed)...
> > "Jon Lewis" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> >>I think this is the nature of a CheckBox in that the act of getting focus
> >>changes it so BeforeUpdate kicks in whilst the box still has the focus.
> >>Cancel = True then resets it this triggers another BeforeUpdate event as
> >>soon as focus goes to another control control and so-on.
> >>
> >> So basically you can't use Before Update for this.

> >
> > Yes, you can, but you have to undo the control's update as well as
> > cancelling it:
> >
> > Private Sub chkYourCheckbox_BeforeUpdate(Cancel As Integer)
> >
> > If <some condition> Then
> > Cancel = True
> > Me.chkYourCheckbox.Undo
> > End If
> >
> > End Sub
> >
> > I agree with you, Jon, that it doesn't make sense to even to enable the
> > check box if the user isn't allowed to check it. Your proposal to enable
> > or disable the check box in the form's Open event, after checking the
> > current user's authorization, makes perfect sense, and should work
> > regardless of whether the database is split or not.
> >
> > --
> > Dirk Goldgar, MS Access MVP
> > Access tips: www.datagnostics.com/tips.html
> >
> > (please reply to the newsgroup)
> >

>
>
> .
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Allow user to change the state of ("click" in) check-boxes on protected worksheets? Chuck Zissman Microsoft Excel Worksheet Functions 2 12th May 2007 08:10 PM
How to disallow someone to change MAC address? bolero92@yahoo.com Microsoft Windows 2000 Registry 2 12th Jul 2006 04:10 PM
change default state of check box =?Utf-8?B?U2NyYXBwaW5nTW9tbWE=?= Microsoft Access Getting Started 2 13th May 2006 11:10 PM
how do I change the default state of a check box in Access 2000? =?Utf-8?B?U2NyYXBwaW5nTW9tbWE=?= Microsoft Access 1 13th May 2006 04:33 AM
ListView with Check Boxes, Disallow check Michael Jackson Microsoft Dot NET Framework Forms 0 9th Aug 2005 05:05 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:41 PM.