button.visible = false on continuous form

  • Thread starter Thread starter Jeffro
  • Start date Start date
J

Jeffro

Looking for some help...

I've got a continuous form with a textbox called Actions
and a button beside it called AddAction2.

If there is data inside the Actions textbox, then I want
the AddActions button to become invisible or disabled.

The following code is not working and I am not sure why. I
put it into the Form_Current() section.

If Me!Actions.Value = Null Then
Me!AddAction2.Visible = False
End If

Can anyone help me please?
 
Jeffro said:
Looking for some help...

I've got a continuous form with a textbox called Actions
and a button beside it called AddAction2.

If there is data inside the Actions textbox, then I want
the AddActions button to become invisible or disabled.

The following code is not working and I am not sure why. I
put it into the Form_Current() section.

If Me!Actions.Value = Null Then
Me!AddAction2.Visible = False
End If

Can anyone help me please?

You can't really do this on a continuous form, because there is really
only one instance of each control, just drawn multiple times. So when
you show or hide a control, you do it for all records. It would be nice
if conditional formatting included the ability to set a control's
Visible property, but it doesn't.

What you can do as a workaround is to create another text box, make it
slightly bigger in all dimensions than the AddAction2 button, and
position it on top of the button so that it completely covers it up.
Then set that text box's properties as follows:

Back Style: Transparent
Special Effect: Flat
Border Style: Transparent
Fore Color: (the same as that of the form's detail section)
Font Name: Terminal
Font Size: (big enough to completely fill the text box)
Enabled: No
Locked: Yes
Control Source: =IIf(IsNull([Actions]), String(100,"Û"), Null)

The "Û" character is the Chr(219), the character that in the Terminal
font totally fills the space with a block character. This, in
conjunction with the IIf() expression, will cover up the button whenever
the Actions control has a Null value.
 
That is a genius answer...thanks very much.

Two problems...

The you wrote the control source is working backwards for
me. If actions is null, then I want the button to appear,
if it's not null...I want the button gone. It's working
backwards and I only know enough to be dangerous with
Access.

Secondly...for the records where you can see the
AddActions2 Button...you can't click it...I'm assuming
because the txtbox is on top of it...

am I missing some vb code in the background???

Thanks for all the help!
-----Original Message-----
Jeffro said:
Looking for some help...

I've got a continuous form with a textbox called Actions
and a button beside it called AddAction2.

If there is data inside the Actions textbox, then I want
the AddActions button to become invisible or disabled.

The following code is not working and I am not sure why. I
put it into the Form_Current() section.

If Me!Actions.Value = Null Then
Me!AddAction2.Visible = False
End If

Can anyone help me please?

You can't really do this on a continuous form, because there is really
only one instance of each control, just drawn multiple times. So when
you show or hide a control, you do it for all records. It would be nice
if conditional formatting included the ability to set a control's
Visible property, but it doesn't.

What you can do as a workaround is to create another text box, make it
slightly bigger in all dimensions than the AddAction2 button, and
position it on top of the button so that it completely covers it up.
Then set that text box's properties as follows:

Back Style: Transparent
Special Effect: Flat
Border Style: Transparent
Fore Color: (the same as that of the form's detail section)
Font Name: Terminal
Font Size: (big enough to completely fill the text box)
Enabled: No
Locked: Yes
Control Source: =IIf(IsNull([Actions]), String (100,"Û"), Null)

The "Û" character is the Chr(219), the character that in the Terminal
font totally fills the space with a block character. This, in
conjunction with the IIf() expression, will cover up the button whenever
the Actions control has a Null value.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


.
 
Jeff said:
That is a genius answer...thanks very much.

Two problems...

The you wrote the control source is working backwards for
me. If actions is null, then I want the button to appear,
if it's not null...I want the button gone. It's working
backwards and I only know enough to be dangerous with
Access.

Oops, I guess I got it backward. You can just reverse the second and
third arguments of the IIf() ControlSource expression:

=IIf(IsNull([Actions]), Null, String (100,"Û")l)
Secondly...for the records where you can see the
AddActions2 Button...you can't click it...I'm assuming
because the txtbox is on top of it...

am I missing some vb code in the background???

Hmm, that's a tricky one. The "hider" text box has to be on top of the
button, or it won't hide it ... How about this? Put a *second* command
button on *top* of the hider text box. Set this button's Transparent
property to True, so it won't be seen, and set its Tab Stop property to
No so that the user won't naturally tab into it. Either put the
original button's OnClick code into this button's event procedure, or
else just call that button's Click event procedure from this button's
Click event procedure, but in either case preface it with an If test to
see if it should be executed or not:

Private Sub cmdTransparentButton_Click()

If IsNull(Me!Actions) Then
Call AddActions2_Click
End If

End Sub
 
Dirk Goldgar wrote:

[snip]
What you can do as a workaround is to create another text box, make it
slightly bigger in all dimensions than the AddAction2 button, and
position it on top of the button so that it completely covers it up.
Then set that text box's properties as follows:

Back Style: Transparent
Special Effect: Flat
Border Style: Transparent
Fore Color: (the same as that of the form's detail section)
Font Name: Terminal
Font Size: (big enough to completely fill the text box)
Enabled: No
Locked: Yes
Control Source: =IIf(IsNull([Actions]), String(100,"Û"), Null)

The "Û" character is the Chr(219), the character that in the Terminal
font totally fills the space with a block character. This, in
conjunction with the IIf() expression, will cover up the button whenever
the Actions control has a Null value.


Dirk, some systems may provide less than satisfactory
results using the Terminal font. See my article for details
and a "problem free" alternative font:

http://www.mvps.org/access/forms/frm0055.htm
 
Marshall Barton said:
Dirk Goldgar wrote:

[snip]
What you can do as a workaround is to create another text box, make
it slightly bigger in all dimensions than the AddAction2 button, and
position it on top of the button so that it completely covers it up.
Then set that text box's properties as follows:

Back Style: Transparent
Special Effect: Flat
Border Style: Transparent
Fore Color: (the same as that of the form's detail section)
Font Name: Terminal
Font Size: (big enough to completely fill the text box)
Enabled: No
Locked: Yes
Control Source: =IIf(IsNull([Actions]), String(100,"Û"), Null)

The "Û" character is the Chr(219), the character that in the Terminal
font totally fills the space with a block character. This, in
conjunction with the IIf() expression, will cover up the button
whenever the Actions control has a Null value.


Dirk, some systems may provide less than satisfactory
results using the Terminal font. See my article for details
and a "problem free" alternative font:

http://www.mvps.org/access/forms/frm0055.htm

Thanks for the heads-up, Marsh. I chose Terminal because it's pretty
much always available, but I didn't realize there were variations
between OS versions. I guess the developer will have to decide whether
to go with a possibly-imperfect-but-always-installed font, or take the
trouble to install a font with the application.

I have a question about this remark: "MS LineDraw is the most commonly,
but not universally, available font that has a character with a fairly
acceptable solid block appearance. However, the character is not quite
full height and leaves a thin line of the background color at the top of
a text box." Why can't one just set the font size of the text box
larger than will fit in the actual height of the text box? Would that
still leave the thin line at the top? If so, how about working around
that by making the text box taller than the control it's covering and
positioning its top a bit higher, so that the thin uncovered line is
already over the detail section?
 
Dirk said:
[snip]
What you can do as a workaround is to create another text box, make
it slightly bigger in all dimensions than the AddAction2 button, and
position it on top of the button so that it completely covers it up.
Then set that text box's properties as follows:

Back Style: Transparent
Special Effect: Flat
Border Style: Transparent
Fore Color: (the same as that of the form's detail section)
Font Name: Terminal
Font Size: (big enough to completely fill the text box)
Enabled: No
Locked: Yes
Control Source: =IIf(IsNull([Actions]), String(100,"Û"), Null)

The "Û" character is the Chr(219), the character that in the Terminal
font totally fills the space with a block character. This, in
conjunction with the IIf() expression, will cover up the button
whenever the Actions control has a Null value.

"Marshall Barton" wrote
Dirk, some systems may provide less than satisfactory
results using the Terminal font. See my article for details
and a "problem free" alternative font:

http://www.mvps.org/access/forms/frm0055.htm
Dirk said:
Thanks for the heads-up, Marsh. I chose Terminal because it's pretty
much always available, but I didn't realize there were variations
between OS versions. I guess the developer will have to decide whether
to go with a possibly-imperfect-but-always-installed font, or take the
trouble to install a font with the application.

I have a question about this remark: "MS LineDraw is the most commonly,
but not universally, available font that has a character with a fairly
acceptable solid block appearance. However, the character is not quite
full height and leaves a thin line of the background color at the top of
a text box." Why can't one just set the font size of the text box
larger than will fit in the actual height of the text box? Would that
still leave the thin line at the top? If so, how about working around
that by making the text box taller than the control it's covering and
positioning its top a bit higher, so that the thin uncovered line is
already over the detail section?


Since the characters are drawn from the top down, the thin
line at the top will always be there.

The issue I ran into with trying to adjust the top of the
text box is that the Terminal font varies between systems
and versions, so what works on one machine may not work on
another.

The whole issue of fonts is a can of worms, kind of like its
own private variation of DLL Hell. Better to have a purpose
built font that you can rely on.
 
Marshall Barton said:
Since the characters are drawn from the top down, the thin
line at the top will always be there.

Ah, I was afraid of that.
The issue I ran into with trying to adjust the top of the
text box is that the Terminal font varies between systems
and versions, so what works on one machine may not work on
another.

The whole issue of fonts is a can of worms, kind of like its
own private variation of DLL Hell. Better to have a purpose
built font that you can rely on.

You've convinced me.
 
Back
Top