From: Kurt Heisler on
Bummer. Was hoping for less code.

On Apr 27, 2:52 pm, John W. Vinson
<jvinson(a)STOP_SPAM.WysardOfInfo.com> wrote:
> On Tue, 27 Apr 2010 10:15:02 -0700 (PDT), Kurt Heisler <heislerk...(a)gmail..com>
> wrote:
>
> >Both options ...
>
> >John's: Me.txtColors.Enabled = (Me.cboFavColor IN ("Green", "Blue"))
>
> >and
>
> >Douglass': Me.txtColors.Enabled = IIf(Me.cboFavColor IN ("Green",
> >"Blue"), -1, 0)
>
> >... give this error:
>
> >"Compile error: Expected: )  " and highlight the IN.
>
> Hrm. Rats... can't use SQL syntax in this context!
>
> You'll need to use OR:
>
> Me.txtColors.Enabled = (Me.cboFavColor="Green" OR Me.cboFavColor="Blue")
> --
>
>              John W. Vinson [MVP]

From: Kurt Heisler on
I also discovered that if you don't use the IIf ... .-1, 0 arguments,
you will get an "Invalid Use of Null" error if the user deletes his
selection (and leaves the field blank), or if you put the line in the
forms OnCurrent event (which is usually desirable in order to enforce
the conditions when moving from record to record).

On Apr 27, 2:52 pm, John W. Vinson
<jvinson(a)STOP_SPAM.WysardOfInfo.com> wrote:
> On Tue, 27 Apr 2010 10:15:02 -0700 (PDT), Kurt Heisler <heislerk...(a)gmail..com>
> wrote:
>
> >Both options ...
>
> >John's: Me.txtColors.Enabled = (Me.cboFavColor IN ("Green", "Blue"))
>
> >and
>
> >Douglass': Me.txtColors.Enabled = IIf(Me.cboFavColor IN ("Green",
> >"Blue"), -1, 0)
>
> >... give this error:
>
> >"Compile error: Expected: )  " and highlight the IN.
>
> Hrm. Rats... can't use SQL syntax in this context!
>
> You'll need to use OR:
>
> Me.txtColors.Enabled = (Me.cboFavColor="Green" OR Me.cboFavColor="Blue")
> --
>
>              John W. Vinson [MVP]

First  |  Prev  | 
Pages: 1 2
Prev: Combo Box Wizard
Next: countdown timer