From: John W. Vinson on 14 May 2010 11:57 On Fri, 14 May 2010 05:36:01 -0700, alekm <alekm(a)discussions.microsoft.com> wrote: >Hi, >here is my code event procedure for a check box. I want to allow some users >to change its state and to prevent otheres from change it. Is there any way I >can ban that SendKeys "{ESC}" line? That line is the only way it works not >ending in the loop (you press anything on the form, msgbox pops up again), >but I don't see why?? > > >Private Sub MyCheckBox_BeforeUpdate(Cancel As Integer) > >If currentuser <> "RightUser" Then > > MsgBox ("You are not right user. You don't touch this check box.") > Cancel = True > SendKeys "{ESC}" > ' without last line msgbox pops up again and again when you press > ' anything on the form > ' only escape key stops it. Why?! > >End If If you don't want a user to check a checkbox, don't LET them check it in the first place! Try putting code in the Form's Current or Load event: Me!MyCheckbox.Enabled = (CurrentUser = "RightUser") -- John W. Vinson [MVP]
From: Krzysztof Naworyta on 14 May 2010 12:58 Juzer BruceM via AccessMonster.com <u54429(a)uwe> napisał | A check box as an option group control does not have Before Update, but | a single check box bound to a table field does. You are wrong :) Single checkbox can have BeforeUpdate subrutine but it does not work! You can not take OldValue for example. You can not cancel this event. | If you use the After Update event as you have shown the value will be | updated, and the After Update code will run again, which means the | value will be updated, and the After Update code will run again.... | The user will be able to do nothing but click the message box button | over and over. You are wrong! Updating any control from code NEVER triggers AfterUpdate event. -- KN
From: Krzysztof Naworyta on 14 May 2010 13:09 Juzer Krzysztof Naworyta <k.naworyta(a)datacomp.com.pl> napisał || A check box as an option group control does not have Before Update, but || a single check box bound to a table field does. | | You are wrong :) | Single checkbox can have BeforeUpdate subrutine but it does not work! | You can not take OldValue for example. You can not cancel this event. Ups! I was wrong!!! Sorry! -- KN
From: Dirk Goldgar on 14 May 2010 13:12 "Krzysztof Naworyta" <k.naworyta(a)datacomp.com.pl> wrote in message news:hsjvg9$c8g$1(a)news.onet.pl... > Juzer BruceM via AccessMonster.com <u54429(a)uwe> napisał > > | A check box as an option group control does not have Before Update, but > | a single check box bound to a table field does. > > You are wrong :) > Single checkbox can have BeforeUpdate subrutine but it does not work! > You can not take OldValue for example. You can not cancel this event. You are wrong. <g> For a standalone checkbox, the BeforeUpdate procedure does work. If the checkbox is bound, its .OldValue property works just fine, and you *can* cancel the event. However, you must also Undo the checkbox if you want it to revert to its original value. -- Dirk Goldgar, MS Access MVP Access tips: www.datagnostics.com/tips.html (please reply to the newsgroup)
From: Rick Brandt on 14 May 2010 13:52 John W. Vinson wrote: > If you don't want a user to check a checkbox, don't LET them check it in > the first place! > > Try putting code in the Form's Current or Load event: > > Me!MyCheckbox.Enabled = (CurrentUser = "RightUser") I'm assuming that this would be the proper method according to standard UI practice, but in my experience disabling a control is likely to generate a support call of "why is this control disabled?" whereas using BeforeUpdate to display a message explaining why they are not allowed to use that control does not.
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: How do I check the current value of check box not reffering it Next: Email problem |