Results 1 to 6 of 6
  1. #1
    joecamel9166 is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Feb 2016
    Posts
    85

    Use Checkbox to Set Record as Default

    So I have multiple shipping addresses for each customer. I can select the customer, then I have a query defining the ship to combo box where I can select the shipping addresses for that customer.
    I added a checkbox to my tblCustShip and to my subCustShip.

    Right now when I select the customer(cmbCust), its subform(subCustomer) loads, then I have to go to cmbCustShip and when I select the address, its subform loads.



    What I want to do, if possible, is use a checkbox on subCustShip to assign that record as the default. So when I select the customer, not only does that load subCustomer, but subCustShip loads as well to the default record.
    Also on top of that, I would like to make that checkbox only valid on one record. so if record3 has the checkbox set to true, then I set the checkbox for record5 to true, record3 checkbox is automatically set to false.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    put the check box in the sub form,
    connect the checkbox to the table field.DEFAULT

    then when the sub form loads, just mark the one you want to be default.
    BUT you have to unmark any previous checks. I cant think of a way to prevent multiple checks=yes.

  3. #3
    joecamel9166 is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Feb 2016
    Posts
    85
    Thank you! I got it to work, but it makes more work having to deselect the check boxes. If you (or anyone else) can think of a way to do this, please let me know. Otherwise I will just have to leave it as it is.

  4. #4
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    You could use the After Update Event of the checkbox to clear all the other checkboxes for that customer if the current one was selected. This means you will need a field or fields to uniquely identify the current address record (could just be an autonumber). The code in the After Update event might look something like this:

    Code:
    if Checkbox = true then
      SQL = "Update tblAddress set chkDefault = False where Customer_ID = " & me!Cust_ID & " AND Address_ID <> " & me!AddressID
      currentdb.execute SQL, dbFailOnError
      me.requery   
    endif
    Replace all the names I use with the actual names in your table and form.

  5. #5
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    yeah, that.

  6. #6
    joecamel9166 is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Feb 2016
    Posts
    85
    Thanks guys. As always, your help is much appreciated!!!

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

Similar Threads

  1. Checkbox default value problem
    By shod90 in forum Forms
    Replies: 4
    Last Post: 01-10-2016, 02:31 PM
  2. Replies: 4
    Last Post: 12-19-2013, 05:35 PM
  3. Replies: 12
    Last Post: 10-27-2012, 05:44 AM
  4. Clearing Checkbox on New Record
    By rossi45 in forum Programming
    Replies: 5
    Last Post: 04-16-2012, 05:30 PM
  5. Replies: 3
    Last Post: 06-27-2009, 03:53 PM

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