Which form event would I use?

G

Guest

I want to make control1 on my form not visible if control2 = X. I have this
code in the Exit event of control2. Additionally, I am also carrying forward
the value of Control2 to new records. This works fine until I begin cycling
through records without exiting control2. Of course when I do that, the last
state of control2 when it was exited is applying to all records.

I believe I need to attach my code to the form, so that when I cycle through
records, control2 is looked at and control1 is visible, or not.

What I don't know is what form event do I use?
 
F

fredg

I want to make control1 on my form not visible if control2 = X. I have this
code in the Exit event of control2. Additionally, I am also carrying forward
the value of Control2 to new records. This works fine until I begin cycling
through records without exiting control2. Of course when I do that, the last
state of control2 when it was exited is applying to all records.

I believe I need to attach my code to the form, so that when I cycle through
records, control2 is looked at and control1 is visible, or not.

What I don't know is what form event do I use?

A better event than the Exit event would be the AfterUpdate event.
Anyway place the same code in the Form's Current event:

Me![Control1].Visible = Me![Control2] = X

(if X is a number, or ="X" if X is Text)
 
G

Guest

Nice, I didn't know you could use this syntax:
Me![Control1].Visible = Me![Control2] = X

I'm presently using an If Then statement.

There are actually three values of Control2 that should set Control1 to not
visible. Could I then use:
Me![Control1].Visible = Me![Control2] = X Or Me![Control2] = Y Or
Me![Control2] = Z

?

fredg said:
I want to make control1 on my form not visible if control2 = X. I have this
code in the Exit event of control2. Additionally, I am also carrying forward
the value of Control2 to new records. This works fine until I begin cycling
through records without exiting control2. Of course when I do that, the last
state of control2 when it was exited is applying to all records.

I believe I need to attach my code to the form, so that when I cycle through
records, control2 is looked at and control1 is visible, or not.

What I don't know is what form event do I use?

A better event than the Exit event would be the AfterUpdate event.
Anyway place the same code in the Form's Current event:

Me![Control1].Visible = Me![Control2] = X

(if X is a number, or ="X" if X is Text)
 

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