Can't enable formatcondition

P

PeeOed

I've been trying to create a table & then form "on the fly" with fields
based on values from a table. For each active employee, I create a
daily schedule and want to display each time slot differently depending
on the appointment type.

The form works great except the conditional formatting. Once created,
I switch design mode & select "Conditional Formating". The formatting
shows correct, but does work in the form until I click "Ok" on the
"Conditional Formatting" menu in design mode.

I've checked the formatconditions(x).enabled value and returns True.
All the MS text says i can set this value, but when I try, I get an
error that "can't assign a value to the object".

HELP - I'm at a loss - everything seems to set OK, except it doesn't
take effect until I go in design mode and click OK on the "format
conditions" window. Here's the code that set's the controls (pEmpCount
is a Public variable couting the number of employees):

DoCmd.OpenForm "frmApptBook", acDesign, , , , acHidden
Dim frm_AB As Form
Dim CtrlLabel As Control, CtrlText As Control
Dim objFrc As FormatCondition
Set frm_AB = Forms!frmApptbook

'* Create controls for each Active Employee
For ctr = 1 To pEmpCount
Set CtrlText = CreateControl("frmApptBook", acTextBox,
acDetail, , "DisplayTxt" & Trim(Str$(ctr)), 1440 * (ctr * 0.9271 -
0.2188), 0, 1440 * 0.9271, 1440 * 0.1771)
CtrlLabel.Name = "txtEmp" & Trim(Str$(ctr))
CtrlLabel.Caption = "Emp" & Trim(Str$(ctr))
CtrlLabel.BackColor = 10040115
CtrlLabel.ForeColor = 16777164
CtrlLabel.BackStyle = 1
CtrlLabel.FontName = "Arial"
CtrlLabel.FontSize = 10
CtrlLabel.FontWeight = 700
CtrlLabel.BorderStyle = 1
CtrlLabel.BorderColor = 16776960
CtrlLabel.TextAlign = 2

CtrlText.Name = "DisplayTxt" & Trim(Str$(ctr))
CtrlText.CanGrow = False
CtrlText.BackColor = 16777215
CtrlText.ForeColor = 0
CtrlText.BackStyle = 1
CtrlText.FontName = "Arial"
CtrlText.SpecialEffect = 0
CtrlText.BorderStyle = 1
CtrlText.OnClick = "=OpenfrmApptPopup()"
Set objFrc = CtrlText.FormatConditions.Add(acFieldHasFocus)
objFrc.BackColor = 13421619
objFrc.ForeColor = 0
objFrc.Enabled = True
‘ NOTE The above gives me an error – but without I bypass it, the
changes formatcondition settings do not take affect!
Set objFrc = CtrlText.FormatConditions.Add(acFieldValue,
acGreaterThan, "!")
objFrc.BackColor = 13434828
objFrc.ForeColor = 0
objFrc.Enabled = True
Set objFrc = CtrlText.FormatConditions.Add(acFieldValue,
acNotBetween, "a", "Z")
objFrc.BackColor = 255
objFrc.ForeColor = 16777215
'objFrc.Enabled = True


Next ctr
DoCmd.OpenForm "frmApptBook", acNormal

Any helpful hint
 

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