Results 1 to 3 of 3
  1. #1
    tylerg11 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Sep 2011
    Posts
    200

    Toggle Button Criteria

    I have a Toggle Button control on my form. I would like to make the "Control Source" of the toggle button based on whether or not a certain text box on my form contains a value. Is this possible?

    For Example, The Toggle Button source would be -1 if a different text box contains data.

  2. #2
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I have a Toggle Button control on my form. I would like to make the "Control Source" of the toggle button based on whether or not a certain text box on my form contains a value. Is this possible?

    For Example, The Toggle Button source would be -1 if a different text box contains data.
    Not quite sure where you are headed....

    You say "Toggle Button" and "Control Source", so it sounds like you have a toggle button that is not in a frame (option group). "Control Source" refers to the field in the current recordsource that the toggle button is bound to.... so having a "control source" of -1 (True) does not make sense.

    You can make the toggle button change state to show untoggled/up/0/FALSE or toggled/down/-1/TRUE by checking if the text box has an entry using the form's Current event:

    Code:
    Private Sub Form_Current()
       Me.Toggle12 = Len(Me.Text14)
    End Sub
    (You would also need code in the text box after update event to set the state of the toggle button after editing the text box.)



    -------------------
    The way the code works is that if the length of the value of the text box is zero, the value of the toggle button is set to FALSE (zero/button up). If the value of the text box is not zero, the value of the toggle button is set to TRUE (-1/button down).

    FALSE is defined as a zero state. TRUE is defined as Not FALSE (ie not zero). So anything that is not zero is True... doesn't matter if it is positive or negative, it is still True.

    "TRUE", in Access, is defined as -1.
    "TRUE", in Excel, is defined as +1.

    If you use TRUE and FALSE in code, the code is transferable between Access and Excel without modification. If you hard code -1 or 1 you will have errors or unexplained errors / values.


    Does this help?

  3. #3
    tylerg11 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Sep 2011
    Posts
    200
    Yes. Thanks.

    I was trying to say that instead of having a seperate control source for the toggle, could I base the True/False values on whether or not a certain text field on my form contains data.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 06-27-2012, 10:57 AM
  2. How to create a datasheet toggle button
    By tobydobo in forum Access
    Replies: 7
    Last Post: 02-06-2012, 01:12 PM
  3. Making a toggle button hide a text box.
    By RemonKoybito in forum Forms
    Replies: 3
    Last Post: 05-20-2011, 11:34 AM
  4. Toggle Button on Bound Form
    By P5C768 in forum Forms
    Replies: 7
    Last Post: 12-30-2010, 03:00 PM
  5. Toggle Button Options
    By Matthieu in forum Forms
    Replies: 2
    Last Post: 11-23-2009, 04:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums