Re: Graying out control not working
From: Pat Dools (PatDools_at_discussions.microsoft.com)
Date: 01/17/05
- Next message: Sandra Daigle: "Re: Graying out control not working"
- Previous message: John Vinson: "Re: Graying out control not working"
- In reply to: Sandra Daigle: "Re: Graying out control not working"
- Next in thread: Sandra Daigle: "Re: Graying out control not working"
- Reply: Sandra Daigle: "Re: Graying out control not working"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 16 Jan 2005 20:53:01 -0800
Hi Sandra,
Thanks for the tip-- it works great. A quick question:
I literally used just this line of code:
Me!Frame9surg_sterl.Enabled =me.sexcode="f"
Is it Best Practice to declare a variable, and, if so, would it be declared
as a String? Or is it really unnecessary if I've put 'Option Explicit' for
this Event Procedure (in the "After Update' Event)?? This code isn't part of
a Module (as in the 'Module' section of the database), per se. This code
appears w/ the other Event Procedure code tied to this particular form. Hope
I'm not just stuck on semantics, but I'm a bit of a code novice.
"Sandra Daigle" wrote:
> Try comparing to the quoted "f" instead of f . If you do not have "Option
> Explicit" in the module header your code is comparing the combo to the
> undeclared variable f. Make sure that you have "Option Explicit" in the
> header of all of your modules to prevent undeclared variables from being
> used.
>
> To simplify this code you can instead use:
>
> Me!Frame9surg_sterl.Enabled =me.sexcode="f"
>
> Be sure you also include this code on the current event of the form if you
> want the control to be toggled when you navigate to existing records.
>
> --
> Sandra Daigle
> [Microsoft Access MVP]
> For the benefit of others please post all replies to this newsgroup.
>
> Pat Dools wrote:
> > Hello,
> >
> > I have some code that is based on the user's choice from a combo box field
> > ('sexcode'), whose values are derived from a Value List
> > ("f";"female";"m";"male"). I have code to gray out the next control
> > ('Frame9surg_sterl') if the user chooses "male", but to keep it Enabled if
> > "female" is chosen. What happens is that 'Frame9surg_sterl' is grayed out
> > regardless of what the user chooses. I have this working elsewhere in my
> > database, but this is the first time I'm attempting to do this using a
> > combo box populated by an alphanumeric value from a Value List instead of
> > a number. What is my code (below) missing here?
> >
> > Private Sub sexcode_AfterUpdate()
> > Dim sexcode As String
> > If sexcode = f Then
> > Me!Frame9surg_sterl.Enabled = True
> > Else
> > Me!Frame9surg_sterl.Enabled = False
> > End If
> > End Sub
>
>
- Next message: Sandra Daigle: "Re: Graying out control not working"
- Previous message: John Vinson: "Re: Graying out control not working"
- In reply to: Sandra Daigle: "Re: Graying out control not working"
- Next in thread: Sandra Daigle: "Re: Graying out control not working"
- Reply: Sandra Daigle: "Re: Graying out control not working"
- Messages sorted by: [ date ] [ thread ]