conditional formatting in VB ( a step further)

M

markk hhoward

I want to change the format of the date field's look
and the Name field's look on the condition of a check box.
I can get the field's to lock and diable on check = -1
any ideas?
does anyone have a list of the avaliable codes??
ie:Forms!frmPlan![Pre-Con].SetFocus

at the moment I have this code
but I can not unlock the date field on check = 0
nor can I change the look to flat instead of sunken

Private Sub Pre_Con_Analysis_Date_Enter()
If [Completed pre con] = -1 Then
Forms!frmPlanProcessing![Pre-Con Analysis
Comments].SetFocus
Forms.frmPlanProcessing.[Pre-Con Analysis
Date].Locked = True
Forms.frmPlanProcessing.[Pre-Con Analysis
Date].Enabled = False
Forms.frmPlanProcessing.
[Precon_analysis_name].Locked = True
Forms.frmPlanProcessing.
[Precon_analysis_name].Enabled = False
Forms.frmPlanProcessing.
[Precon_analysis_name].Effect = Flat
ElseIf [Completed pre con] = 0 Then
Forms!frmPlanProcessing![Pre-Con Analysis
Comments].SetFocus
Forms.frmPlanProcessing.[Pre-Con Analysis
Date].Locked = False
Forms.frmPlanProcessing.[Pre-Con Analysis
Date].Enabled = True
Forms.frmPlanProcessing.
[Precon_analysis_name].Locked = False
Forms.frmPlanProcessing.
[Precon_analysis_name].Enabled = True
End If

End Sub
 
S

SteveS

Try this:

Private Sub Pre_Con_Analysis_Date_Enter()
'check box ([Completed pre con]) is checked
If Me.[Completed pre con] Then
Me.[Pre-Con Analysis Comments].SetFocus
Me.[Pre-Con Analysis Date].Locked = True
Me.[Pre-Con Analysis Date].Enabled = False
Me.[Precon_analysis_name].Locked = True
Me.[Precon_analysis_name].Enabled = False
Me.[Precon_analysis_name].Effect = Flat

'if not true then do this (check box not checked)
Else
Me.[Pre-Con Analysis Comments].SetFocus
Me.[Pre-Con Analysis Date].Locked = False
Me.[Pre-Con Analysis Date].Enabled = True
Me.[Precon_analysis_name].Locked = False
Me.[Precon_analysis_name].Enabled = True
End If
End Sub

You are using the OnEnter event of the date control and the first action
is to move the focus to the comments control.???
So any time you enter the date control, you get kicked to the
comments control; how will you ever change the date?

As for the flat (normal) instead of sunken look up 'SpecialEffect' in
Help (VBA).
The syntax is

Me.YourControlName.SpecialEffect = vbConstant

where vbConstant is one of these:
acEffectNormal
acEffectChisel
acEffectRaised
acEffectEtched
acEffectShadow
acEffectSunken

Steve
 

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