PC Review


Reply
Thread Tools Rate Thread

Changing the visibility of Textbox/Label Based on Two Checkboxes

 
 
R Tanner
Guest
Posts: n/a
 
      20th Oct 2008
Hi,

I have a userform with two checkboxes. One I have named Yes and one I
have labeled No.

This is my code in the No Event procedure

UserForm2.Yes.Value = _
Not UserForm2.Yes.Value

This is my code in the Yes event procedure

UserForm2.No.Value = _
Not UserForm2.No.Value

It works perfectly. The problem is that I want to add code to change
the visibility of the textbox and label directly below it. When I try
what I have below, it screws everything up and the checkboxes don't
work correctly.

This is what I have in each of the event procedures right above the
above code I just displayed:

Yes_Click

Select Case UserForm2.Yes.Value
Case Is = "True"
UserForm2.SendToRepLabel.Visible = True
Case Is = "False"
UserForm2.SendToRepLabel.Visible = False
End Select

No_Click

Select Case UserForm2.Yes.Value
Case Is = "True"
UserForm2.SendToRepLabel.Visible = True
Case Is = "False"
UserForm2.SendToRepLabel.Visible = False
End Select


Any ideas what this is doing that is screwing up my checkboxes? I
mean, the select statements are not modifying the value of the
checkboxes, so why would it screw with their behavior?

Thanks
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      20th Oct 2008
You are probably triggering each checkboxes click event from the other. Use
a boolean to control, like this


Private Sub Yes_Click()

If Not fReEntry Then

With Me

fReEntry = True

'your code

fReEntry = False
End With
End If

End Sub

--
__________________________________
HTH

Bob

"R Tanner" <(E-Mail Removed)> wrote in message
news:62660b38-2752-4274-ac58-(E-Mail Removed)...
> Hi,
>
> I have a userform with two checkboxes. One I have named Yes and one I
> have labeled No.
>
> This is my code in the No Event procedure
>
> UserForm2.Yes.Value = _
> Not UserForm2.Yes.Value
>
> This is my code in the Yes event procedure
>
> UserForm2.No.Value = _
> Not UserForm2.No.Value
>
> It works perfectly. The problem is that I want to add code to change
> the visibility of the textbox and label directly below it. When I try
> what I have below, it screws everything up and the checkboxes don't
> work correctly.
>
> This is what I have in each of the event procedures right above the
> above code I just displayed:
>
> Yes_Click
>
> Select Case UserForm2.Yes.Value
> Case Is = "True"
> UserForm2.SendToRepLabel.Visible = True
> Case Is = "False"
> UserForm2.SendToRepLabel.Visible = False
> End Select
>
> No_Click
>
> Select Case UserForm2.Yes.Value
> Case Is = "True"
> UserForm2.SendToRepLabel.Visible = True
> Case Is = "False"
> UserForm2.SendToRepLabel.Visible = False
> End Select
>
>
> Any ideas what this is doing that is screwing up my checkboxes? I
> mean, the select statements are not modifying the value of the
> checkboxes, so why would it screw with their behavior?
>
> Thanks



 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      20th Oct 2008
Forgot to say, fReEntry should be declared as module scope variable

Private fReEntry As Boolean

before any procedures

--
__________________________________
HTH

Bob

"R Tanner" <(E-Mail Removed)> wrote in message
news:62660b38-2752-4274-ac58-(E-Mail Removed)...
> Hi,
>
> I have a userform with two checkboxes. One I have named Yes and one I
> have labeled No.
>
> This is my code in the No Event procedure
>
> UserForm2.Yes.Value = _
> Not UserForm2.Yes.Value
>
> This is my code in the Yes event procedure
>
> UserForm2.No.Value = _
> Not UserForm2.No.Value
>
> It works perfectly. The problem is that I want to add code to change
> the visibility of the textbox and label directly below it. When I try
> what I have below, it screws everything up and the checkboxes don't
> work correctly.
>
> This is what I have in each of the event procedures right above the
> above code I just displayed:
>
> Yes_Click
>
> Select Case UserForm2.Yes.Value
> Case Is = "True"
> UserForm2.SendToRepLabel.Visible = True
> Case Is = "False"
> UserForm2.SendToRepLabel.Visible = False
> End Select
>
> No_Click
>
> Select Case UserForm2.Yes.Value
> Case Is = "True"
> UserForm2.SendToRepLabel.Visible = True
> Case Is = "False"
> UserForm2.SendToRepLabel.Visible = False
> End Select
>
>
> Any ideas what this is doing that is screwing up my checkboxes? I
> mean, the select statements are not modifying the value of the
> checkboxes, so why would it screw with their behavior?
>
> Thanks



 
Reply With Quote
 
R Tanner
Guest
Posts: n/a
 
      22nd Oct 2008
On Oct 20, 3:24*pm, "Bob Phillips" <Bob...@somewhere.com> wrote:
> Forgot to say, fReEntry should be declared as module scope variable
>
> Private fReEntry As Boolean
>
> before any procedures
>
> --
> __________________________________
> HTH
>
> Bob
>
> "R Tanner" <tanner.ro...@gmail.com> wrote in message
>
> news:62660b38-2752-4274-ac58-(E-Mail Removed)...
>
>
>
> > Hi,

>
> > I have a userform with two checkboxes. One I have named Yes and one I
> > have labeled No.

>
> > This is my code in the No Event procedure

>
> > UserForm2.Yes.Value = _
> > * *Not UserForm2.Yes.Value

>
> > This is my code in the Yes event procedure

>
> > UserForm2.No.Value = _
> > * *Not UserForm2.No.Value

>
> > It works perfectly. *The problem is that I want to add code to change
> > the visibility of the textbox and label directly below it. *When I try
> > what I have below, it screws everything up and the checkboxes don't
> > work correctly.

>
> > This is what I have in each of the event procedures right above the
> > above code I just displayed:

>
> > Yes_Click

>
> > Select Case UserForm2.Yes.Value
> > * *Case Is = "True"
> > * * * *UserForm2.SendToRepLabel.Visible = True
> > * *Case Is = "False"
> > * * * *UserForm2.SendToRepLabel.Visible = False
> > End Select

>
> > No_Click

>
> > Select Case UserForm2.Yes.Value
> > * *Case Is = "True"
> > * * * *UserForm2.SendToRepLabel.Visible = True
> > * *Case Is = "False"
> > * * * *UserForm2.SendToRepLabel.Visible = False
> > End Select

>
> > Any ideas what this is doing that is screwing up my checkboxes? *I
> > mean, the select statements are not modifying the value of the
> > checkboxes, so why would it screw with their behavior?

>
> > Thanks- Hide quoted text -

>
> - Show quoted text -


Okay thank you for the info...
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamically update userform label based on textbox macroapa Microsoft Access 4 29th Jan 2011 09:16 PM
Changing recordset based on multiple checkboxes Joseph Greenberg Microsoft Access Form Coding 1 4th Dec 2009 07:11 AM
How do I hide a label based on the value of a textbox FrunkaBlunka Microsoft Access Forms 2 20th Oct 2006 01:50 AM
label visibility based on report field? =?Utf-8?B?QnJvb2s=?= Microsoft Access Reports 4 30th Apr 2005 01:38 AM
Changing textbox or label =?Utf-8?B?YW5kcmV3?= Microsoft Access Reports 1 8th May 2004 04:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:56 AM.