Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22
  1. #16
    Micron is online now Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    June is so far into this that I hesitate to go over the same ground, and June is more capable than me for sure. But I do have a suggestion to shorten code that you might be able to make use of. Instead of 50-ish lines that set properties such as .visible, consider something like



    Code:
    dim ctl as control
    For each ctl in me.controls
        if ctl.type='acControlTypeGoesHere' AND ctl.tag="yourTag" then
           ctl.visible = true or false as you wish
        end if
    next ctl
    If you want to apply this to more than one type, it's probably easier to trap the error that is generated when you try to set a property on a control which does not have that property. In the error handler, you RESUME for that error number. I don't remember the number...

  2. #17
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Micron, if you can download the db and get the form to open without error, please continue.

    Whether or not the shorter code will perform faster I can't say for sure. Might depend on how many controls must be cycled through. Directly setting visibility property of a few controls might be faster than cycling through hundreds.
    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.

  3. #18
    bradp1979 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2015
    Location
    San Francisco, CA
    Posts
    234
    Just now figured it out. The lines of code naming Me.lbl____.Visible = False, etc. was in the VBA twice. I just had to find the second one, and add Me.lblExpected.Visible = False and Me.lblParked.Visible = False to vendor 44 and 48, and Me.lblExpected.Visible = True and Me.lblParked.Visible = True after the Else statement in both places. Now it works.

  4. #19
    Micron is online now Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Interesting, because my point was not about speed - it was about less typing, easier to read/follow and less chance for screw-ups. Easy enough to modify object tags too. Glad you got it solved!

  5. #20
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    I know you intended to save on typing but typing is done once, the procedure must run repeatedly. Shouldn't performance be a consideration in coding?
    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.

  6. #21
    Micron is online now Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Of course performance is always a consideration and I did not mean to imply otherwise. Had I known there were "hundreds" of controls on his form that were of the textbox type, I still would advocate this method for where it makes sense.

    I do not know what the limit would be before you would notice a performance hit, but I can tell you that you would need to get the system time in milliseconds before and after each routine to notice a much of a difference with 100 or so controls. Even when I have stepped over this routine in the vbe on a form with over 100 controls, the processing time is around a second or so. Like many repeatable tasks, it can also be called as a function in a standard module where you pass the control type and tag text as values, thus reusing over many projects. That would be worth 1 or 2 seconds of processing time in my opinion. In this case, it might even have prevented the issue.

    With all due respect, I reiterate: my point was not about code execution speed, it was about passing on a method which has certain advantages that one could take or leave depending on their situation, because I seek to inform as well as learn here.

  7. #22
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    I don't know if form has hundreds of controls nor whether the performance would suffer, just trying to inform OP of things to consider. I do I have some complex form/subform arrangements that are already slow enough so I use the 'long' code.
    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.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Variable Column Headings
    By asparks16 in forum Queries
    Replies: 1
    Last Post: 06-28-2012, 07:58 PM
  2. Replies: 8
    Last Post: 05-14-2012, 09:49 AM
  3. csv import second row contains column headings
    By dr_patso in forum Import/Export Data
    Replies: 1
    Last Post: 07-16-2011, 03:56 PM
  4. Resizing column headings
    By allykid in forum Access
    Replies: 0
    Last Post: 03-10-2011, 12:58 PM
  5. Cross Tab Column Headings...
    By mhoctober in forum Queries
    Replies: 3
    Last Post: 09-10-2010, 01:21 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