IF Statements - multiple "do this" criteria

G

Guest

Hi Guys,

When using an IF statement can I do something like this?

If Me.Confirmed = -1 Then
Me.txtDate.Locked = True And Me.txtDate.ForeColor = vbRed
Else...

EndIf etc

Basically I can't use conditional formatting because the criteria is
checking whether a checkbox is ticked. If the box is ticked I basically want
to lock the control and change the forecolour to Red. Currently the lock
works but not the ForeColor property.

Cheers for any helpful hints & tips


Wendy
 
B

Brendan Reynolds

That would be ...

If Me.Confirmed = -1 Then
Me.txtDate.Locked = True
Me.txtDate.ForeColor = vbRed
Else...

EndIf etc

In other words, you can insert multiple statements between the If and the
Else (or between the Else and the EndIf).
 
F

fredg

Hi Guys,

When using an IF statement can I do something like this?

If Me.Confirmed = -1 Then
Me.txtDate.Locked = True And Me.txtDate.ForeColor = vbRed
Else...

EndIf etc

Basically I can't use conditional formatting because the criteria is
checking whether a checkbox is ticked. If the box is ticked I basically want
to lock the control and change the forecolour to Red. Currently the lock
works but not the ForeColor property.

Cheers for any helpful hints & tips

Wendy

Place this code in the Form's Current event as well as the [Confirmed]
AfterUpdate event:

If Me!Confirmed = -1 Then
Me!txtDate.ForeColor = vbRed
Me!txtDate.Locked = True
Else
Me!txtDate.ForeColor = vbBlack
Me!txtDate.Locked = False
End If
 
T

Tim Ferguson

I basically want
to lock the control and change the forecolour to Red. Currently the lock
works but not the ForeColor property.

Odd things happen to colours when you set the Enabled and Locked
properties. Are you sure that Access will honour your ForeColor setting on
a locked control?

HTH


Tim F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top