Page 1 of 3 123 LastLast
Results 1 to 15 of 33
  1. #1
    ShaunG is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jan 2018
    Posts
    237

    changing mulitple controls to true or false on subform at once

    im hoping this is a quick fix that someone can help me with, im trying to load a form and have all the controls for the field switched to false automatically.



    the fields are toggle buttons.

    i have tried various codes but my problem is it only sets the very first record toggle to false and the rest under that one are left at true or the other way around depending on what im trying to acheive.

    if any one could help would be much appreciated. thanks.

    ive tried in the on load, on current event but my coding isnt getting me far

    one code ive tried

    if me!subform1.form!cmdselectorder = False then
    me!subform1.form!cmdorder = False

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    Can you post 2 images of the form, design view and form view?

  3. #3
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    I'm confused by this phrase 'all the controls for the field'
    Do you mean all form controls?

    One easy way to do this may be to use the controls' tag property.
    Hold the Ctrl button down on the keyboard whilst you select all the controls you want updated. Now give all of these the same tag value e g. TF

    Then add code to Form load event to loop through each control in turn.
    If ctrl.Tag ="TF" Then....set control value false.

    Or easier still, just set the default value of each of those controls =false,

    HTH
    Last edited by isladogs; 09-03-2018 at 02:37 AM.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Is this multiple toggle controls for one record or one control and multiple records? Control(s) bound to field(s)? If bound, why change value in record? Is this multi-user db?
    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.

  5. #5
    ShaunG is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jan 2018
    Posts
    237
    Quote Originally Posted by davegri View Post
    Can you post 2 images of the form, design view and form view?
    yes davegri ill do that now

  6. #6
    ShaunG is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jan 2018
    Posts
    237
    Quote Originally Posted by ridders52 View Post
    I'm confused by this phrase 'all the controls for the fields
    Do you mean all form controls?

    One easy way to do this may be to use the controls' tag property.
    Hold the Ctrl button down on the keyboard whilst you select all the controls you want updated. Now give all of these the same tag value e g. TF

    Then add code to Form load event to loop through each control in turn.
    If ctrl.Tag ="TF" Then....set control value false.

    Or easier still, just set the default value of each of those controls =false,

    HTH
    thanks ridders52 i wasn't aware of how to do that and i reckon thats what im after, ill give it a shot and let you know.

  7. #7
    ShaunG is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jan 2018
    Posts
    237
    Hi june, there are multiple toggle control fields on the continuous subform, but im only wanting one of the fields to be set to either true or false when form loads thats because im querying the forms and using the toggle controls to help with my query.
    yes it is a muli- user db. its to load orders that are selected on to a new page with an order number attached to it.

  8. #8
    ShaunG is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jan 2018
    Posts
    237
    here is the design and layout mode.
    Attached Thumbnails Attached Thumbnails design mode.jpg   layout view.jpg  

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    If multiple users are accessing same form and same records and each setting values in these records, they will conflict.
    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.

  10. #10
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Aside from the multiple concurrent user comment, you're dealing with a continuous form. Code like what you have will only affect one record (always the 1st in the form recordset?) in a continuous form. There is only one instance of your control on the form, right? In which record would you have Access affect the value in the field that's bound to this control? If not the first, you'd have to know the PK value for the record you wish to update. If it is to be all, then you'd have to either loop through the form recordset and update per record or run an update query against the table then requery the form.

    I have to wonder why you want to modify one field in one record via code, then run some query based on the change. Why not just let the user make the update? I don't think you've said enough about what you want to have happen, or what the process is, for us to comment about whether or not you're even on the right track. At least, that's my opinion for what it's worth.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  11. #11
    ShaunG is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jan 2018
    Posts
    237
    Quote Originally Posted by June7 View Post
    If multiple users are accessing same form and same records and each setting values in these records, they will conflict.
    I understand your concern June7 but i think in my situation they are ok in a multi-user environment.
    The reasons for my toggle fields are for instance, when they are all green or true the query removes them from being selected again as they would be assigned to an order number.
    this problem of mine could be me being over the top for example if i select say 10 records then i load the form ive attached to put the records into an order and assign an OrderNumber.
    Im wanting all the toggle controls for field - (add products to order) for the 10 records to be set to true on load to assigns the OrderNumber to each record.
    Then if someone makes a mistakes and added a product by accident they can click the toggle control (add products to order) for that record which will set it to false and then remove the OrderNumber from that record only.
    I also have it set up so that when the toggle control field - (add products to order) is set to false the toggle control field -(unselect to remove product) will also be set to false. this is so when the previous form is opened nothing is selected to put into a new order.

    i hope all that makes sense.

  12. #12
    ShaunG is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jan 2018
    Posts
    237
    Quote Originally Posted by Micron View Post
    Aside from the multiple concurrent user comment, you're dealing with a continuous form. Code like what you have will only affect one record (always the 1st in the form recordset?) in a continuous form. There is only one instance of your control on the form, right? In which record would you have Access affect the value in the field that's bound to this control? If not the first, you'd have to know the PK value for the record you wish to update. If it is to be all, then you'd have to either loop through the form recordset and update per record or run an update query against the table then requery the form.

    I have to wonder why you want to modify one field in one record via code, then run some query based on the change. Why not just let the user make the update? I don't think you've said enough about what you want to have happen, or what the process is, for us to comment about whether or not you're even on the right track. At least, that's my opinion for what it's worth.
    Hi Micron hopefully I've explained it well enough in my reply to June7 for my reasons. yea correct it is a continuous subform and yes only one of my controls updates with my coding abilities at the moment but will try riddlers52 suggestion.

  13. #13
    ShaunG is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jan 2018
    Posts
    237
    Quote Originally Posted by ridders52 View Post
    I'm confused by this phrase 'all the controls for the fields
    Do you mean all form controls?

    One easy way to do this may be to use the controls' tag property.
    Hold the Ctrl button down on the keyboard whilst you select all the controls you want updated. Now give all of these the same tag value e g. TF

    Then add code to Form load event to loop through each control in turn.
    If ctrl.Tag ="TF" Then....set control value false.

    Or easier still, just set the default value of each of those controls =false,

    HTH
    riddlers52 i tried your idea written below and come up with a compile error - variable not defined. this below look correct ive never referred to tags before sorry. i also have tried setting the default value to false or true 0 or -1 but still had no luck with it changing for some reason

    Private Sub Form_Load()
    If IsNull(Me!txtOrderDate1) Then
    Me.txtOrderDate1 = Date
    If IsNull(Me.txtOrderedBy1) Then
    Me.txtOrderedBy1 = [Forms]![LoginForm]![cboUser].Column(1)
    End If
    If ctrl.Tag = "SelectProduct" Then
    Set Control = False
    End if
    End If
    End Sub

  14. #14
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Conventional approach is a main form bound to Orders table and subform bound to OrderDetails table and select product from combobox. Subform container control master/child links properties synchronize related records. To delete product from order select record and hit delete key. Toggle button looks like unnecessary complication.
    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.

  15. #15
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    When I first suggested two code solutions, I wasn't aware that you were taking about multiple 'copies' of the same control in a continuous form.
    You can't do what you want.
    As you can see from design view, each record is actually using the same control.
    So if the first toggle is made true, it becomes true for all records.

    Similarly if you wanted to disable a button in a continuous form, it is disabled for all records.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

Page 1 of 3 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 8
    Last Post: 10-06-2014, 03:02 PM
  2. True And False
    By azhar2006 in forum Forms
    Replies: 4
    Last Post: 12-23-2013, 03:50 AM
  3. Currency fields and if to get true/false
    By Ruegen in forum Programming
    Replies: 1
    Last Post: 09-29-2013, 07:40 PM
  4. Yes/No True/False
    By DSTR3 in forum Access
    Replies: 5
    Last Post: 12-04-2010, 05:56 PM
  5. True or false
    By tleec in forum Queries
    Replies: 1
    Last Post: 02-01-2008, 10:41 AM

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