Text Box = Visible (True or False)

  • Thread starter Douglas J. Steele
  • Start date
T

Tom

Does anyone know what's wrong w/ the IF statement below?


If Me.State.Value = "--" Then
Me.State.Visible = False
Else
Me.State.Visible = True
End If

I don't want to show the "state" textfield if the country
is e.g. Spain or France (for which I don't use state
values such as AZ, CA, TX, VA, etc.).

Currrently, I either show or don't show the state value
text box on the form (regardless of wha the value in the
state field is).

Again, I'd appreciate any pointers that will hide/unhide
the textbox depending on the value.

Thanks,
Tom
 
S

Sandra Daigle

Hi Tom,

Your code would only work if you are actually storing the literal string
"--" into the State field when not needed. Instead, I would toggle the
visible property of the control based on the value in the Country control -
add the following to the AfterUpdate and Current events of the form. FWIW, I
would probably do this with the enabled property instead of visible but it's
your call :)

me.State.visible=me.Country <> "USA"
 
T

Tom

Doug:

Thanks for your prompt reply...

oh, yeah, I should have included the event name. I
placed the code into the "On Open" event (see below).

If I switch the TRUE/FALSE value I am able to unhide/hide
the text box. Nevertheless, it's still not working.

Tom



Private Sub Form_Open(Cancel As Integer)

If Me.State.Value = "--" Then
Me.State.Visible = False
Else
Me.State.Visible = True
End If

End Sub
 
T

Tom

Sandra:

Thanks for your quick turn-around...

Hmh, that's an idea... I tried it State.Visible to
Country dependeny in the On Open form.

You suggested the AfterUpdate... the form that pulls the
information is purely for Read-Only and data will not be
updated in that particular form.

Currently, I have the following in the On Open Event of
the form... it still does not work though.

Tom


Private Sub Form_Open(Cancel As Integer)
Me.State.visible=me.Country <> "USA"
End Sub




-----Original Message-----
Hi Tom,

Your code would only work if you are actually storing the literal string
"--" into the State field when not needed. Instead, I would toggle the
visible property of the control based on the value in the Country control -
add the following to the AfterUpdate and Current events of the form. FWIW, I
would probably do this with the enabled property instead of visible but it's
your call :)

me.State.visible=me.Country <> "USA"


--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.
Does anyone know what's wrong w/ the IF statement below?


If Me.State.Value = "--" Then
Me.State.Visible = False
Else
Me.State.Visible = True
End If

I don't want to show the "state" textfield if the country
is e.g. Spain or France (for which I don't use state
values such as AZ, CA, TX, VA, etc.).

Currrently, I either show or don't show the state value
text box on the form (regardless of wha the value in the
state field is).

Again, I'd appreciate any pointers that will hide/unhide
the textbox depending on the value.

Thanks,
Tom

.
 
S

Sandra Daigle

If it is read-only then you should probably use the Current event. This
event fires when the focus moves to a record. I think the Open event is too
soon. Even the Load event would only catch the first record. Try it with the
Current event and let me know if you still have problems.

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.
Sandra:

Thanks for your quick turn-around...

Hmh, that's an idea... I tried it State.Visible to
Country dependeny in the On Open form.

You suggested the AfterUpdate... the form that pulls the
information is purely for Read-Only and data will not be
updated in that particular form.

Currently, I have the following in the On Open Event of
the form... it still does not work though.

Tom


Private Sub Form_Open(Cancel As Integer)
Me.State.visible=me.Country <> "USA"
End Sub




-----Original Message-----
Hi Tom,

Your code would only work if you are actually storing the literal string
"--" into the State field when not needed. Instead, I would toggle the
visible property of the control based on the value in the Country control -
add the following to the AfterUpdate and Current events of the form.
FWIW, I would probably do this with the enabled property instead of
visible but it's your call :)

me.State.visible=me.Country <> "USA"


--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.
Does anyone know what's wrong w/ the IF statement below?


If Me.State.Value = "--" Then
Me.State.Visible = False
Else
Me.State.Visible = True
End If

I don't want to show the "state" textfield if the country
is e.g. Spain or France (for which I don't use state
values such as AZ, CA, TX, VA, etc.).

Currrently, I either show or don't show the state value
text box on the form (regardless of wha the value in the
state field is).

Again, I'd appreciate any pointers that will hide/unhide
the textbox depending on the value.

Thanks,
Tom

.
 
T

Tom

Sanda:

EXCELLENT!!! This works great!

I now understand the difference between "On Open"
and "Current".

Thanks so much for sharing the information.

Tom


-----Original Message-----
If it is read-only then you should probably use the Current event. This
event fires when the focus moves to a record. I think the Open event is too
soon. Even the Load event would only catch the first record. Try it with the
Current event and let me know if you still have problems.

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.
Sandra:

Thanks for your quick turn-around...

Hmh, that's an idea... I tried it State.Visible to
Country dependeny in the On Open form.

You suggested the AfterUpdate... the form that pulls the
information is purely for Read-Only and data will not be
updated in that particular form.

Currently, I have the following in the On Open Event of
the form... it still does not work though.

Tom


Private Sub Form_Open(Cancel As Integer)
Me.State.visible=me.Country <> "USA"
End Sub




-----Original Message-----
Hi Tom,

Your code would only work if you are actually storing the literal string
"--" into the State field when not needed. Instead, I would toggle the
visible property of the control based on the value in the Country control -
add the following to the AfterUpdate and Current events of the form.
FWIW, I would probably do this with the enabled property instead of
visible but it's your call :)

me.State.visible=me.Country <> "USA"


--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Tom wrote:
Does anyone know what's wrong w/ the IF statement below?


If Me.State.Value = "--" Then
Me.State.Visible = False
Else
Me.State.Visible = True
End If

I don't want to show the "state" textfield if the country
is e.g. Spain or France (for which I don't use state
values such as AZ, CA, TX, VA, etc.).

Currrently, I either show or don't show the state value
text box on the form (regardless of wha the value in the
state field is).

Again, I'd appreciate any pointers that will hide/unhide
the textbox depending on the value.

Thanks,
Tom

.

.
 
S

Sandra Daigle

You're welcome :)

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.
Sanda:

EXCELLENT!!! This works great!

I now understand the difference between "On Open"
and "Current".

Thanks so much for sharing the information.

Tom


-----Original Message-----
If it is read-only then you should probably use the Current event. This
event fires when the focus moves to a record. I think the Open event is too
soon. Even the Load event would only catch the first record. Try it with
the Current event and let me know if you still have problems.

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.
Sandra:

Thanks for your quick turn-around...

Hmh, that's an idea... I tried it State.Visible to
Country dependeny in the On Open form.

You suggested the AfterUpdate... the form that pulls the
information is purely for Read-Only and data will not be
updated in that particular form.

Currently, I have the following in the On Open Event of
the form... it still does not work though.

Tom


Private Sub Form_Open(Cancel As Integer)
Me.State.visible=me.Country <> "USA"
End Sub





-----Original Message-----
Hi Tom,

Your code would only work if you are actually storing the literal
string "--" into the State field when not needed. Instead, I would
toggle the visible property of the control based on the value in the
Country control - add the following to the AfterUpdate and Current
events of the form. FWIW, I would probably do this with the enabled
property instead of visible but it's your call :)

me.State.visible=me.Country <> "USA"


--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Tom wrote:
Does anyone know what's wrong w/ the IF statement below?


If Me.State.Value = "--" Then
Me.State.Visible = False
Else
Me.State.Visible = True
End If

I don't want to show the "state" textfield if the country
is e.g. Spain or France (for which I don't use state
values such as AZ, CA, TX, VA, etc.).

Currrently, I either show or don't show the state value
text box on the form (regardless of wha the value in the
state field is).

Again, I'd appreciate any pointers that will hide/unhide
the textbox depending on the value.

Thanks,
Tom

.

.
 

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