using a Check Box to Hide fields

T

TheNovice

Good Morning,

I have a SubForm that I am using for Data Entry, Some of the information is
not necessary to enter if the checkbox has been selected.

Two Fields need to be hidden, One is a Combo-Box (Product) and the other is
a TextBox (ProdDescFormula)

I have tried using the following and am not sure if this is correct. I have
used it in other MDB's but the difference is that this is a SubForm.

Product.Visible = Not NC90
or
Me.Product.Visible = Not NC90

ProdDescFormula.Visible = Not NC90
or
Me.ProdDescFormula.Visible = Not NC90

any and all help or guidance would be appreciated
 
D

Duane Hookom

How/where is this code being called? On Current, After Update, Before Udate,
multiple events,...?
 
D

Duane Hookom

You stated what you wanted, some code you tried, and where you tried it but
you didn't say whether or not it was working and what your results were.
 
C

Carlos Marques

TheNovice said:
Good Morning,

I have a SubForm that I am using for Data Entry, Some of the information is
not necessary to enter if the checkbox has been selected.

Two Fields need to be hidden, One is a Combo-Box (Product) and the other is
a TextBox (ProdDescFormula)

I have tried using the following and am not sure if this is correct. I have
used it in other MDB's but the difference is that this is a SubForm.

Product.Visible = Not NC90
or
Me.Product.Visible = Not NC90

ProdDescFormula.Visible = Not NC90
or
Me.ProdDescFormula.Visible = Not NC90

any and all help or guidance would be appreciated
--
-The Novice
Learn Today, Teach Tomorrow

Great Success is ones ability to ask for Help.
 
C

Carlos Marques

If you are refering to a field in a subform from the main form you need to
refer it like this:
Me![Subformname].Form.[Fieldname].Value
 
T

TheNovice

No it is not working, and at times it gives me an error to Debug. it tells
me that the error is unknown. I have tried 100 to sunday but the fields do
not disappear.

what I wondered if it was to do that it is a Combo box? but why wouldnt the
Textbox disappear also?
 
T

TheNovice

Would i place that on "OnCurrent"?
--
-The Novice
Learn Today, Teach Tomorrow

Great Success is ones ability to ask for Help.


Carlos Marques said:
If you are refering to a field in a subform from the main form you need to
refer it like this:
Me![Subformname].Form.[Fieldname].Value

TheNovice said:
Good Morning,

I have a SubForm that I am using for Data Entry, Some of the information is
not necessary to enter if the checkbox has been selected.

Two Fields need to be hidden, One is a Combo-Box (Product) and the other is
a TextBox (ProdDescFormula)

I have tried using the following and am not sure if this is correct. I have
used it in other MDB's but the difference is that this is a SubForm.

Product.Visible = Not NC90
or
Me.Product.Visible = Not NC90

ProdDescFormula.Visible = Not NC90
or
Me.ProdDescFormula.Visible = Not NC90

any and all help or guidance would be appreciated
--
-The Novice
Learn Today, Teach Tomorrow

Great Success is ones ability to ask for Help.
 
D

Duane Hookom

The code should be in the On Current (or after update) of the form
containing the controls.
 
P

Peter R. Fletcher

To do this properly, you need code in two places:
1) The OnCurrent Event
2) The AfterUpdate Event of your CheckBox

In the OnCurrent event, you need to check whether you are on the new
record (Me.NewRecord = True). If so, you set the visibility of your
two optional fields to the default values (presumably .Visible=True).
If you aren't on the new record, you need code such as you have, to
set them according to the saved value of the CheckBox

In the AfterUpdate Event of the Checkbox, you need code to set the
visibility of the optional fields according to the new state of the
CheckBox.

It shouldn't matter whether you are in a subform or not.

Good Morning,

I have a SubForm that I am using for Data Entry, Some of the information is
not necessary to enter if the checkbox has been selected.

Two Fields need to be hidden, One is a Combo-Box (Product) and the other is
a TextBox (ProdDescFormula)

I have tried using the following and am not sure if this is correct. I have
used it in other MDB's but the difference is that this is a SubForm.

Product.Visible = Not NC90
or
Me.Product.Visible = Not NC90

ProdDescFormula.Visible = Not NC90
or
Me.ProdDescFormula.Visible = Not NC90

any and all help or guidance would be appreciated

Please respond to the Newsgroup, so that others may benefit from the exchange.
Peter R. Fletcher
 
Top