Results 1 to 8 of 8
  1. #1
    bauer1544 is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2020
    Posts
    8

    Check box keeps being read as true in If statement


    I am trying to have a label become Visable and turn off additions and deletions when the check box is true. also i have never written in SQl before but here is the code I currently have.


    Private Sub CheckLock()
    If chkLocked = True Then
    lblLocked.Visible = True
    Me.AllowDeletions = False
    Me.AllowEdits = False
    Else
    lblLocked.Visible = False
    Me.AllowAdditions = True
    Me.AllowEdits = True

    End If






    End Sub

    a few other things
    1: chkLocked is 100% sure the field name
    2. it is definitely reading it as true
    3. this is ran on an OnActivate for the form
    4. it treats forms with check box checked the same as forms where the check box is not checked

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    3. this is ran on an OnActivate for the form
    Try it in the form's On_Current

  3. #3
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Does it work if you put the code in the forms OnCurrent event.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    How are you calling it, or do you have the same code in multiple forms (from #4 it sounds like multiple forms anyway)? Is there a variable with the same name that could be confusing things? I'd use Me to disambiguate.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    bauer1544 is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2020
    Posts
    8
    Like I said I’m new to this but what would the variable be here? I don’t believe I set any. Also, this is written in MainForm>properties>onActivate . Later it will be copied to the sub forms within that main form but right now it’s just on the “Main” one.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Can you attach the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    bauer1544 is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2020
    Posts
    8
    this actually did solve the issue but I'm not sure what the difference or potential issue is with putting it in "on current" vs "on activate" would be i just know that on the original one I am replicating this if statement was in the on activate

  8. #8
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    Quote Originally Posted by bauer1544 View Post
    this actually did solve the issue but I'm not sure what the difference or potential issue is with putting it in "on current" vs "on activate" would be i just know that on the original one I am replicating this if statement was in the on activate
    Without knowing the details of the interactions within your DB, I can't tell you why the original code was in the form's OnActivate or whether changing it to OnCurrent has any side effects. The apparent main side effect so far is that it works.

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

Similar Threads

  1. How to tell a query if check box = true, then...
    By dwheatley in forum Queries
    Replies: 6
    Last Post: 11-28-2017, 06:40 PM
  2. Replies: 41
    Last Post: 12-06-2016, 08:40 AM
  3. Replies: 7
    Last Post: 08-02-2016, 01:19 PM
  4. True/False Check Box Usage in Forms
    By avicknair in forum Access
    Replies: 3
    Last Post: 11-12-2015, 12:54 PM
  5. Replies: 4
    Last Post: 02-03-2014, 12:16 PM

Tags for this Thread

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