Enabled

S

Stephanie

Hello! I know this should be easy, but I've gone through many iterations.

I'm trying to say that if ArtistDonor is Artist (=1), then enable
Commissions and default Commissions to "yes".

Private Sub Form_Current()
Me.Commission.Enabled = (Me.ArtistDonor = 1)
Me.Commission.DefaultValue = "yes"

End Sub

I keep getting an invalid use of Null which happens with a new record-
Commissions gets enabled and defaulted to yes even though Artist hasn't been
selected. In this case: Me.Commision.Enable is true and Me.ArtistDonor =
Null.

I tried versions of If statements, but seem to get it all backwards and
would appreciate some help. Thanks!
 
A

Allen Browne

Use Nz() to specify a value to use for null, e.g.:

Private Sub Form_Current()
Me.Commission.Enabled = Nz((Me.ArtistDonor = 1), False)
Me.Commission.DefaultValue = True
End Sub
 
S

Stephanie

You make it seem easy! That did the trick, but here's my Event question:
when I select Artist (=1), the Commission field doesn't become visible until
I leave the record and then come back to it. Which isn't so handy if I'm
entering an Artist and want to set the commission to "no".

Am I using the correct Event? Do I need to add something to another Event?
Thanks!
 
A

Amit

Stephanie said:
You make it seem easy! That did the trick, but here's my Event question:
when I select Artist (=1), the Commission field doesn't become visible until
I leave the record and then come back to it. Which isn't so handy if I'm
entering an Artist and want to set the commission to "no".

Am I using the correct Event? Do I need to add something to another Event?
Thanks!

Hi Stephanie,

You'll need to add this code to the AfterUpdate event of the control (I'm
assuming a combo-box) where you enter/select the ArtistDonor value:

Me.Commission.Enabled = (Me.ArtistDonor = 1)
Me.Commission.DefaultValue = "yes"

HTH,

-Amit
 
Top