Results 1 to 3 of 3
  1. #1
    jimgros is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    8

    checkboxes onclick, beforeupdate, afterupdate doesnt work

    Hi everyone,

    First let me describe what i want to do:
    I have a subform with my stock list (datasheet view).
    I want to add checkboxes next to each item to then either print, or sell the selected stock items

    How far have i arrived:
    The datasheet source is a query.

    SELECT Stock.Lot_Nr, checkSelected([stock].[Stock_ID]) AS stockSelected, Stock.Stock_ID
    FROM Stock LEFT JOIN Selected ON Stock.Stock_ID = Selected.stockid;

    I successfully created a checkbox that appears on the datasheet through the query.

    The value of the checkbox is also correctly reflected (testing dummy values). The way I made this work is by using a table "Selected" where I enter the stockID of the selected items. I have a function "CheckSelected" that is called in the query, which basically checks if the item is selected or not. Based on that the checkbox will be on or off.

    Public Function checkSelected(ByVal idofstock As Long) As Boolean
    If (Nz(DLookup("stockid", "Selected", "stockid = " & idofstock), 0) = 0) Then
    checkSelected = False
    Else
    checkSelected = True
    End If
    End Function

    My problem:
    All seems fine, except that now of course I want to click checkboxes and add or remove selected stockitems from table "Selected"

    HOWEVER: the onclick or beforeupdate or afterupdate events of the checkbox are not responding.


    I even tried to put a simple msgbox in those event, no other code. Nothing appears....
    The dblclick event works, the gotfocus event works, but I can't seem to change the checkbox value using simple clicks...

    Pls help?
    much appreciated

    I have created a db that simulates exactly what i'm trying to do with all the same code and everything. You can use this if you want to better understand.

  2. #2
    jimgros is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    8
    solved!
    I solved my own problem, although i don't find the solution super intuitive.
    If i use the ongotfocus event i can get the checkbox to toggle on and off.
    It's just weird that the more obvious events don't work such as click. Even weirder that doubleclick works.
    Despite the fact that it's solved, if you have an explanation on why it works that way that would be interesting
    thx

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Congratulations! I was going to review your project but glad you found a solution. The few times I have dealt with checkboxes I seem to recall same issue - that those events did not work.
    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. Help I dunno y it doesnt work
    By zaza123 in forum Programming
    Replies: 7
    Last Post: 07-03-2011, 06:43 PM
  2. Call .dll Code On BeforeUpdate?
    By phi11yguy19 in forum Programming
    Replies: 0
    Last Post: 07-02-2011, 10:20 PM
  3. Validation BeforeUpdate Errors
    By huv123 in forum Programming
    Replies: 3
    Last Post: 02-07-2011, 10:25 AM
  4. BeforeUpdate and AfterUpdate Question
    By gsurfdude in forum Programming
    Replies: 0
    Last Post: 04-03-2008, 07:56 AM
  5. My subform doesnt refresh????? HELP!
    By LiamMurphy in forum Forms
    Replies: 1
    Last Post: 03-09-2006, 09:08 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