Results 1 to 4 of 4

Thread: Check Box. On Click happens when record changes

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Posts
    154
    I want to place code in the click event of a check box. However, when you move from one record to the next, it seems to process the on click event. If I am reading documentation correctly, it says it will do this when the record changes and the value changes in the check box. My problem is I do not want it to run my code if you are simply moving from one record to the next. I only want the code processed when the USER clicks the box. I would think this to be reasonable. If the user did not click the box, why should Microsoft click it for you?????? (I am sure they can give me many reasons why, kinda like the problem I was having with package wizard where an error was being generated on an MSCAL.OCX file. I read in Documentation where they said this was meant to happen???? Yes, they said it was there for a reason??????

    Oh well, any ideas on how to get around this issue.

  2. #2
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    Ah VB's famous (read bloody annoying) events.

    To get around this you will need to set a boolean. This is true of a lot of events in VB

    Code:
    'General Declarations
    Dim blMovingRecords As Boolean
    
    Private Sub MoveRecords()
      'where you move records
      
      blMovingRecords = True
      'show the new record
      blMovingRecords = False
    
    End Sub
    
    
    Private Sub Check1_Click()
    
      If blMovingRecords = False
        'your code goes here
      End If
    
    End Sub
    Iain, thats with an i by the way!

  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    check

    are you talking check box as a stand alone or a checkbox as part of a grid or listview.
    the checkbox value is set to false on startup
    and when clicked it turns true and stays true
    until clicked again to return it to the former value.

    you could try in the click event.
    do whatever
    do whatever
    doEvents
    chkThisBox.Value = False

    ...just a thought...haven't run into the problem
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Posts
    154
    Thanks for Responses. I will set a boolean value and go that route.

    HeSaidJoe. The problem is that the CheckBox is a control linked to a database. When I move records, the checkbox shows what is set in the database. It could be true on one record and false on another. Therefore, anytime the value changes, and you have something in the click event, Microsft assumes the user clicked the box because it changed even though the user did nothing but move from one record to the next.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width