Results 1 to 14 of 14
  1. #1
    Cosimo is offline Novice
    Windows 10 Access 2007
    Join Date
    Jan 2024
    Posts
    27

    Changing property on multiple forms


    Is there a way to set the same property on all fifty forms in a database via code at the same time instead of manually one at a time?

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    Yes. What property?

  3. #3
    Cosimo is offline Novice
    Windows 10 Access 2007
    Join Date
    Jan 2024
    Posts
    27

    Setting "Order By On Load" property to "No" on Fifty Forms

    Quote Originally Posted by davegri View Post
    Yes. What property?
    Thank you for offering to help.

    I'd like to set the "Order By On Load" property to "No" on all the forms without having to set that property on each form one at a time.

  4. #4
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    Are you actually using Access 2007? That might be a problem for my vba solution.

    In that case someone else might jump in. The solution algorithm is pretty simple.
    1. Get list of form names in a query.
    2. iterate through the list as a recordset
    3. Open each form in turn in design mode.
    4. Change the property
    5. Close and save the form

  5. #5
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    Cosimo-davegri-v01.zip

    Here's a version written with ac2019. It might work for you.
    form1,2,3, and 4 are just for test. If it works for them, you can try with your database.
    For your database, make a backup copy first.
    Copy cctblFormNames and ccfrmFormChoices to your DB.
    Open ccfrmFormChoices. It must be the ONLY form open. It will list all your forms and subforms. You can move any form you want untouched to the right listbox.

    Click image for larger version. 

Name:	orderby.png 
Views:	31 
Size:	26.8 KB 
ID:	51338
    Last edited by davegri; 01-17-2024 at 12:56 AM. Reason: clarif

  6. #6
    Cosimo is offline Novice
    Windows 10 Access 2007
    Join Date
    Jan 2024
    Posts
    27
    I'm converting an Access 2003 database to Access 2007 and then I will convert it to a more recent, supported Access version. The current 2007 step, is the first step in my conversion project.

    I just stumbled across this code on another Access related website. This code is old and dates from 2006. Does it look like the right idea to set a value for a Form Property (in this case, the code below sets values for the form's X and Y Axes)?
    Dim obj As AccessObject, dbs As Object
    Dim intCount As Integer
    Set dbs = Application.CurrentProject
    For Each obj In dbs.AllForms
    If obj.Type = 2 Then
    DoCmd.OpenForm obj.Name, acDesign
    Forms(obj.Name).GridX = 24
    Forms(obj.Name).GridY = 24
    DoCmd.Close acForm, obj.Name, acSaveYes

    End If
    Next obj

  7. #7
    Edgar is offline Competent Performer
    Windows 8 Access 2016
    Join Date
    Dec 2022
    Posts
    274
    dim frm as form
    for each frm in forms
    frm.properties("the property name").value = "the value"
    next frm

    maybe?


    (if they are open, if not, you have to open them in design mode, i think, on the phone... can't test)
    Please click on the ⭐ below if this post helped you.


  8. #8
    Edgar is offline Competent Performer
    Windows 8 Access 2016
    Join Date
    Dec 2022
    Posts
    274
    dim frm as form
    for each frm in forms
    frm.properties("the property name").value = "the value"
    next frm

    maybe?

    (if they are open, if not, you have to open them in design mode, i think, on the phone... can't test)
    Please click on the ⭐ below if this post helped you.


  9. #9
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    That code looks ok. Not sure what obj.type 2 is.
    Instead of the grid reference

    Forms(obj.Name).OrderByOnLoad = False

  10. #10
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Quote Originally Posted by Cosimo View Post
    Thank you for offering to help.

    I'd like to set the "Order By On Load" property to "No" on all the forms without having to set that property on each form one at a time.
    Unless you have a value in the OrderBy property, I do not think that does anything?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  11. #11
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Fairly certain the order by on load property must be either Y/N (or equivalent). The Order By can be null though?
    Never mind - I think I misunderstood the comment. However, Order By might exist by default:
    When a new object is created, it inherits the RecordSource, Filter, OrderBy, and OrderByOn properties of the table or query that it was created from.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  12. #12
    Cosimo is offline Novice
    Windows 10 Access 2007
    Join Date
    Jan 2024
    Posts
    27
    Quote Originally Posted by davegri View Post
    Cosimo-davegri-v01.zip

    Here's a version written with ac2019. It might work for you.
    form1,2,3, and 4 are just for test. If it works for them, you can try with your database.
    For your database, make a backup copy first.
    Copy cctblFormNames and ccfrmFormChoices to your DB.
    Open ccfrmFormChoices. It must be the ONLY form open. It will list all your forms and subforms. You can move any form you want untouched to the right listbox.

    Click image for larger version. 

Name:	orderby.png 
Views:	31 
Size:	26.8 KB 
ID:	51338
    Thanks for the help, davegri.

    And sorry for the delay responding to you.

    I had a business emergency that I needed to work on (my real job isn't in tech).

    I haven't tried your suggestion, but I will check it out when I have the time. It looks good, though.

    Thanks again.

  13. #13
    Cosimo is offline Novice
    Windows 10 Access 2007
    Join Date
    Jan 2024
    Posts
    27
    Quote Originally Posted by Welshgasman View Post
    Unless you have a value in the OrderBy property, I do not think that does anything?
    Something sneaked into the OrderBy property on some of my forms, likely from using the right click mouse button and making the incorrect choice on the mouse menu.

    This wasn't a problem in Access 2003 when I last used the database. The problem surfaced after I converted the database to Access 2007, which was the version that MS added the "Order by on Load" property to forms, with the default value being "true"; not realizing this at first, havoc ensued when I opened a form for which a value in the form's "sort by" property existed and interfered with the sort order I originally set in the form's record source query. I thought the conversion process had created some kind of corruption!

  14. #14
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Already mentioned
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

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

Similar Threads

  1. Changing image picture property
    By GraeagleBill in forum Forms
    Replies: 12
    Last Post: 06-17-2022, 10:40 AM
  2. Replies: 5
    Last Post: 11-18-2014, 01:42 PM
  3. Changing control property
    By mujaqo in forum Programming
    Replies: 2
    Last Post: 05-23-2013, 09:41 AM
  4. Replies: 3
    Last Post: 01-04-2012, 05:16 PM
  5. Replies: 7
    Last Post: 10-03-2011, 12:44 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