Re: Editable field only based on another field



Well, I never could get the Me![TextBox].Enabled = Me![Checkbox] to work, but
I played around with an IF Expression and it worked for me. If the checkbox
is checked it goes to the following field to allow editing and if it is
unchecked then the next field is uneditable and tabbing through it skips that
field. The code I used goes as follows:

Private Sub Ctl401_k_Participant_AfterUpdate()
If Me![401(k)Participant] = True Then
Me![401(k)%].Enabled = True
Else
Me![401(k)%].Enabled = False
End If
End Sub

I'm still learning about VBA, but this IF conditional express worked for me
in this situation. I was expecting the field in question to be grayed out
when it was uneditable, but it is fine this way.

If you have any tips for me or can help me understand this a little more
that would be great. If not thank you so much for you help.


--
julostarr


"Jeff Boyce" wrote:

If you entered that directly in the space following the label for
AfterUpdate in the properties, Access will try to find a macro with that
name.

To be more specific, you will need to create an AfterUpdate event procedure
and enter that expression in the event procedure.

Regards

Jeff Boyce
Microsoft Office/Access MVP

"julostarr" <julostarr@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:AC30040F-9A11-4173-A5D2-6E070ED669D2@xxxxxxxxxxxxxxxx
Can you help me out with understanding this a little more. I entered
this:

Me![TextBox].Enabled = Me![Checkbox]

in the After Update under properties of my checkbox control, of course
substituting the TestBox name I wanted to enable for TestBox and the same
for
the Checkbox. When I go back to the form view and click the check box I
get
an error saying the the Macro doesn't exist. Am I supposed to build a
macro
or am I entering something wrong.
--
julostarr


"John W. Vinson" wrote:

On Fri, 26 Sep 2008 11:05:41 -0700, "Jeff Boyce" <nonsense@xxxxxxxxxxxx>
wrote:

If I wanted to enable a textbox based on whether a checkbox were
checked,
I'd probably add something like the following in the checkbox's
AfterUpdate
event:

Me!TextBox.Enabled = Me!Checkbox

.... and also the Form's Current event, to handle existing records, I'd
suggest.
--

John W. Vinson [MVP]




.



Relevant Pages

  • Re: Editable field only based on another field
    ... Microsoft Office/Access MVP ... you will need to create an AfterUpdate event ... in the After Update under properties of my checkbox control, ... an error saying the the Macro doesn't exist. ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Editable field only based on another field
    ... you will need to create an AfterUpdate event procedure ... an error saying the the Macro doesn't exist. ... "John W. Vinson" wrote: ...
    (microsoft.public.access.tablesdbdesign)
  • Why do I get this error?
    ... Chris Nebinger ... >I have an event procedure that is supposed to open a form ... >when a checkbox is checked. ... The macro didn't work. ...
    (microsoft.public.access.formscoding)
  • Re: check boxes, eye dots ...
    ... Read the help on afterupdate & find myself in over my head. ... The way i understand it when i create a balloon with check boxes. ... > Put that code in the event procedure for the AfterUpdate event for the ... >> What can i do to this code so that a single click in the checkbox will ...
    (microsoft.public.access.modulesdaovba)
  • Re: check box malfunction
    ... If you can't do this in the macro, it would be a small, simple bit of code ... in an event procedure connected to the 'click' event. ... Microsoft IT Academy Program Mentor ... Does either your checkbox or your macro "know" when the checkbox is ...
    (microsoft.public.access.forms)

Loading