Conditional Formatting - I just don't see what I'm doing wrong.

  • Thread starter Thread starter Dennis
  • Start date Start date
D

Dennis

Hi,

I and running Access via XP Office Pro w/ sp3 on XP Pro w / sp3.

I am trying to get conditional formatting to work, but I am doing something
dumb. I’ve read through a couple of book and the articles on this forum, but
I can not get it to work.

I have a form with the following option fields on the form:

Vendor Address:
Vendor City:
Vendor State:
Vendor Zip:

If Vendor Address is null or I do not enter something for Vendor Address, I
want the remaining fields to be disabled (grayed out).

In the Conditional Formatting under the Format menu, I have the following:

Condition 1 Expression is: [txtVenAddr]=â€â€ Gray out current field.
Condition 2 Expression is: IsNull([txtVenAddr]) Gray out current field.

I also tried:

Condition 1 Expression is: [me.txtVenAddr]=â€â€ Gray out current
field.
Condition 2 Expression is: IsNull([me.txtVenAddr]) Gray out current
field.


I also tried:

Condition 1 Expression is: me.txtVenAddr=â€â€ Gray out current field.
Condition 2 Expression is: IsNull(me.txtVenAddr) Gray out current field.

I also tried setting a public variable (Dim pboolDisableVen as Boolean) at
the top of the program. I then set this variable to True if I want to
disable the vendor information and false if I want the questions asked.

This conditional format is:

Condition 1 Expression is: pboolDisableVen = True Gray out current field.

What I’m doing wrong?


Dennis
 
Hi Dennis,
instead of using the name of the control, as txtVenAddr, use the name of the
field.



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
Dennis said:
I and running Access via XP Office Pro w/ sp3 on XP Pro w / sp3.

I am trying to get conditional formatting to work, but I am doing something
dumb. I’ve read through a couple of book and the articles on this forum, but
I can not get it to work.

I have a form with the following option fields on the form:

Vendor Address:
Vendor City:
Vendor State:
Vendor Zip:

If Vendor Address is null or I do not enter something for Vendor Address, I
want the remaining fields to be disabled (grayed out).

In the Conditional Formatting under the Format menu, I have the following:

Condition 1 Expression is: [txtVenAddr]=”” Gray out current field.
Condition 2 Expression is: IsNull([txtVenAddr]) Gray out current field.

I also tried:

Condition 1 Expression is: me.txtVenAddr=”” Gray out current field.
Condition 2 Expression is: IsNull(me.txtVenAddr) Gray out current field.

I also tried setting a public variable (Dim pboolDisableVen as Boolean) at
the top of the program. I then set this variable to True if I want to
disable the vendor information and false if I want the questions asked.

This conditional format is:

Condition 1 Expression is: pboolDisableVen = True Gray out current field.


Me. is only valid in a VBA class module (includes form and
report modules) so your second try has no hope of working.

Similarly, VBA variables are only recognized in VBA
procedures so your third try can't work either.

Your first try can be done in a single expression using any
of these kinds of expressions:
[txtVenAddr]=”” OR IsNull([txtVenAddr])
or
[txtVenAddr]=”” OR [txtVenAddr] Is Null
or
Nz([txtVenAddr], ””) = ""
or
Len([txtVenAddr] & ””) = 0

If you pay close attention to the VenAddr field in the
table, you can set the AllowZeroLength property to No to
eliminate the possibility of the field ever being set to "".
Although I prefer the disabled approach, the field's
Required property can be used to make sure a value is
entered in the field's bound text box before the record can
be saved back to the table.

All that being said, your first try should work **IF** you
set the conditions on the **other** three text boxes. The
city conditions should be set for the state and zip text
boxes and the state conditions would only be used for the
zip text box.
 
Marshall and Jeanette,

Thank you for your assitance. I got it working using your advice.

Marshall, thank you for the lesson on the scope of variables. I've gone
back to the books (Inside Access 2003 and MS Access 2003 Programming by
Examples) to read about variable scope and lifetime.

Thank you both for pointing me in the right direction. I finally know why I
have not been able to get conditionally formatting to work.


--
Dennis


Marshall Barton said:
Dennis said:
I and running Access via XP Office Pro w/ sp3 on XP Pro w / sp3.

I am trying to get conditional formatting to work, but I am doing something
dumb. I’ve read through a couple of book and the articles on this forum, but
I can not get it to work.

I have a form with the following option fields on the form:

Vendor Address:
Vendor City:
Vendor State:
Vendor Zip:

If Vendor Address is null or I do not enter something for Vendor Address, I
want the remaining fields to be disabled (grayed out).

In the Conditional Formatting under the Format menu, I have the following:

Condition 1 Expression is: [txtVenAddr]=â€â€ Gray out current field.
Condition 2 Expression is: IsNull([txtVenAddr]) Gray out current field.

I also tried:

Condition 1 Expression is: me.txtVenAddr=â€â€ Gray out current field.
Condition 2 Expression is: IsNull(me.txtVenAddr) Gray out current field.

I also tried setting a public variable (Dim pboolDisableVen as Boolean) at
the top of the program. I then set this variable to True if I want to
disable the vendor information and false if I want the questions asked.

This conditional format is:

Condition 1 Expression is: pboolDisableVen = True Gray out current field.


Me. is only valid in a VBA class module (includes form and
report modules) so your second try has no hope of working.

Similarly, VBA variables are only recognized in VBA
procedures so your third try can't work either.

Your first try can be done in a single expression using any
of these kinds of expressions:
[txtVenAddr]=â€â€ OR IsNull([txtVenAddr])
or
[txtVenAddr]=â€â€ OR [txtVenAddr] Is Null
or
Nz([txtVenAddr], â€â€) = ""
or
Len([txtVenAddr] & â€â€) = 0

If you pay close attention to the VenAddr field in the
table, you can set the AllowZeroLength property to No to
eliminate the possibility of the field ever being set to "".
Although I prefer the disabled approach, the field's
Required property can be used to make sure a value is
entered in the field's bound text box before the record can
be saved back to the table.

All that being said, your first try should work **IF** you
set the conditions on the **other** three text boxes. The
city conditions should be set for the state and zip text
boxes and the state conditions would only be used for the
zip text box.
 
Back
Top