Results 1 to 3 of 3
  1. #1
    vt800c is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2010
    Posts
    23

    Question checking a query when marking a checkbox

    I have a form that contains employee data. When a person leaves, I don't want to delete them, but I want to mark it as archived (using a checkbox linked to a boolean field). When I click on the checkbox, I want to run a query on a related table, and if any rows are returned, not allow the box to be checked. I want to present a message box to the user telling them why that person can't be archived, to give them the opportunity to rectify the outstanding discrepancies.

    So how do I fire the query and get a return (entier a number, or a null set or ANYthing that I can use as a descriminator)?



    All of you have helped me get up to speed with this and I've used alot of your code and methods. My project is growing nicely and with your assistance I'm creating a very robust and usable application.

    Thank you

  2. #2
    NoellaG's Avatar
    NoellaG is offline VIP
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,045
    Hi,

    you can put some code in the beforeUpdate event of the checkbox control resembling:

    If me.chkMyCheckBox = True then
    lngRecords = DSum("Name_PK_Field","Tablename_related_table","FK _Field = " & me.ControlNamePK_field")
    If lngrecords > 0 then
    Msgbox .................................
    cancel = true
    me.undo
    end if
    end if

    Success
    NG

  3. #3
    vt800c is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2010
    Posts
    23
    BINGO! that was EXACTLY what I neede. Thanks!

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

Similar Threads

  1. Automatically checking a box?
    By Delta223 in forum Access
    Replies: 3
    Last Post: 01-10-2011, 10:37 PM
  2. Checking a table for changes
    By Rando in forum Queries
    Replies: 2
    Last Post: 10-07-2010, 09:25 AM
  3. Date error checking
    By oediaz in forum Programming
    Replies: 2
    Last Post: 03-26-2010, 12:08 PM
  4. Checking for Value in Query
    By jgelpi in forum Access
    Replies: 1
    Last Post: 06-24-2009, 04:57 PM
  5. Checking a record in a table
    By widstje in forum Programming
    Replies: 4
    Last Post: 11-07-2007, 11:28 AM

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