Results 1 to 5 of 5
  1. #1
    database_1 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Mar 2020
    Posts
    34

    Trouble using boolean variable

    I have a checkbox list of yes and no's. I want to be able to check when a button is clicked if both chkbox1 and chkbox2 are false then have a boolean variable equal true if so. I can not seem to be able to call out the boolean variable or use it in the if statement. If you can explain to me how to declare it and use it in this way, that would be greatly appreciated.

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2016
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    A little vba in your form event (you'll have to tell us what you're trying to do)

    Code:
    If me.chkbox1 and me.chkbox2 then
      do something since both are true
    else 
      do something else since both are not true
    end if
    Last edited by orange; 05-21-2020 at 07:24 AM. Reason: spelling

  3. #3
    database_1 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Mar 2020
    Posts
    34
    I have a path of yes and no check boxes that are give a result when a button is clicked once all the choices are filled in. For example, was there an audit (y or n), if yes, was there multiple audits (y or n), if yes what was the number of audits (txtbox). I have set up all of my If statements for every possible choice of the yes's and no's and I am even able to get the value of the textbox. This was all confirmed by using msgboxes. Instead of a msgbox though, I want the if statement to make a boolean variable true or false so I can relate the data to the rest of the form. I just cant seem to get the variable declared correctly or what.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2016
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Perhaps you could show us the code you have and a clear statement of what you are trying to accomplish. or post a copy of the database.
    ??Couldn't you just check the textbox for a non zero value?? based on
    what was the number of audits (txtbox)

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    For a variable to be referenced by multiple procedures, it must be declared in module header. If you want it available to multiple objects, declare variable in a general module header. Declare as Public or Global.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Boolean search?
    By elamadon0228 in forum Queries
    Replies: 10
    Last Post: 11-09-2016, 12:49 PM
  2. Trouble with DCount Using a Variable
    By JustinPinette in forum Modules
    Replies: 5
    Last Post: 10-31-2016, 12:33 PM
  3. Trouble with string variable in custom vba function
    By CurrentUser in forum Programming
    Replies: 4
    Last Post: 01-10-2014, 09:13 PM
  4. Replies: 3
    Last Post: 05-28-2013, 12:53 PM
  5. Trouble With Variable holding Value
    By michaelb in forum Programming
    Replies: 3
    Last Post: 02-25-2011, 11:32 AM

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