Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Object.Visible true/false acc. to a frametoggle value

Status
Not open for further replies.

Quehay

Programmer
Feb 6, 2000
804
US
I'm trying to write code for a form that would toggle the .visible property of several controls (textboxes/labels/memo), based on whether the user chooses toggle &quot;yes&quot; or toggle &quot;no.&quot;<br><br>In the frame_click, the toggle_mousedown (and up) I've tried this sort of approach:<br><br>If framexx.value = 1 (yes) then<br>&nbsp;&nbsp;&nbsp;thisbox.visible = true<br>Else<br>&nbsp;&nbsp;&nbsp;thisbox.visible = false<br>End if<br><br>I've tried using &quot;if&quot; without the &quot;else&quot;; and a nested &quot;if..then&quot; within that substitutes for the &quot;else.&quot;<br><br>This would work in VB6 but I don't yet know the quirks of <br>Access VBA.&nbsp;&nbsp;Any suggestions would be appreciated!!<br><br><br>
 
Instead of using Fram value use the specific controls name<br><br>If Combo1.checked = true then<br>.....<br>ElseIf Combo2.checked = true then<br><br><br>Try this approach
 
basically, you don't need to put &quot;.value&quot; in there, and -1 is standard for yes in Access, not 1.<br><br>just use<br><b><br>If framexx = -1 Then&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;thisbox.visible = True<br>Else<br>&nbsp;&nbsp;&nbsp;&nbsp;thisbox.visible = False<br>End if<br></b><br> <p>Brian Famous<br><a href=mailto:bfamous@ncdoi.net>bfamous@ncdoi.net</a><br><a href= > </a><br>
 
I read somewhere that 0 = No/Off, and <i>anything</i> else is True/On. For this reason I stick with testing on 0. But has anyone ever seen a value other than 0 or -1?
 
Thanks Doug, Brian, and Elizabeth for your help.&nbsp;&nbsp;FYI: Access assigns the values 1 for Yes and 2 for No if a <br>option group is bound to a Yes/No field. This is different from the values returned by a stand-alone option or toggle, I believe.
 
your correct on the 1,2 thing Quehay.&nbsp;&nbsp;i forgot about the option group factor.&nbsp;&nbsp;You can technically assign any value you want to the option groups if i am correct, but it does default to 1,2.<br><br>thanks for the reminder.&nbsp;&nbsp;i hope it all works for you now. <p>Brian Famous<br><a href=mailto:bfamous@ncdoi.net>bfamous@ncdoi.net</a><br><a href= > </a><br>
 
Try this one :<br><br>Sub Form_OnOpen()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Me.[anycontrol].Visible = True ' or false<br>End Sub<br><br>' REM A button to toggle our [anycontrol]<br>Sub Button0_OnClick() <br>&nbsp;&nbsp;&nbsp;&nbsp;<b>[anycontrol].Visible = Not [anycontrol].Visible </b><br>End Sub<br><br>' REM whatever [anycontrol].visible was will be toggled when this code executes.<br>&nbsp;<br><br>Incidently the boolean value 'True' In Access evaluates to -1(number). The boolean value 'False' evaluates to 0 (number).<br><br>Peace.<br> <p>Amiel<br><a href=mailto:amielzz@netscape.net>amielzz@netscape.net</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top