Solved What am I doing wrong...For Each (1 Viewer)

zeroaccess

Active member
Local time
Today, 12:21
Joined
Jan 30, 2020
Messages
671
Since you were concerned about brevity, there is no need for this if then. Simply
ctrl.visible = true
Do not need to check if it is not visible. You do not get an error setting something to visible that is already visible. Not that it makes any practical difference, but it would be slightly more efficient. You are not doing an if check, just setting a property.

If you want to toggle (true to false, false to true), instead of an if then else
ctrl.visible = not ctrl.visible
True, but I think checking first before setting the property can help reduce flicker. That is another thing I am battling with.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:21
Joined
Oct 29, 2018
Messages
21,469
Hi. So many ways to do the same things, aren't there. You could even remove the outer Select Case if you were going to check the Tag property anyway. Just a thought...
 

zeroaccess

Active member
Local time
Today, 12:21
Joined
Jan 30, 2020
Messages
671
I added a small, transparent command button with no tag and no caption to the corner of the screen, and

Screen.ActiveForm!cmdUnseen.SetFocus

Now no focus errors when hiding eligible controls.
 
Last edited:

zeroaccess

Active member
Local time
Today, 12:21
Joined
Jan 30, 2020
Messages
671
Hi. So many ways to do the same things, aren't there. You could even remove the outer Select Case if you were going to check the Tag property anyway. Just a thought...
This actually doesn't work - I get Run-time error '2455' as posted above...
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:21
Joined
Oct 29, 2018
Messages
21,469
This actually doesn't work - I get Run-time error '2455' as posted above...
I am thinking that would depend on how you actually tried it. The original post (in post #1) didn't work because of the wrong use of the OR logical operator. So, which post actually mentioned the 2455 error? Can you post how you've tried simply checking the Tag property with a Select Case without checking for ControlType first but still got an error? Thanks!
 

zeroaccess

Active member
Local time
Today, 12:21
Joined
Jan 30, 2020
Messages
671
Attached for your evaluation.

Utilities needs to be cleaned up some more but you can see how my menu works.
 

Attachments

  • ZA Menu Demo.zip
    737.5 KB · Views: 92

isladogs

MVP / VIP
Local time
Today, 18:21
Joined
Jan 14, 2017
Messages
18,216
Just had a quick look at your demo.
Obviously its not intended to be fully functional as several forms weren't included
I didn't study your code.

It looks good but some comments for you to consider
1. As mentioned previously you do have an issue with flickering which needs addressing.
2. On my 12" tablet some items do not display properly losing the top part of the text e.g. Reports...inspections and admin items
3. I would recommend you replace all embedded macros with VBA
4. I assume your comment on the Run Query buttons is meant to be funny...but will your end users really think so?
 

zeroaccess

Active member
Local time
Today, 12:21
Joined
Jan 30, 2020
Messages
671
Just had a quick look at your demo.
Obviously its not intended to be fully functional as several forms weren't included
I didn't study your code.

It looks good but three comments for you to consider
1. As mentioned previously you do have an issue with flickering which needs addressing.
2. On my 12" tablet some items do not display properly losing the top part of the text e.g. Reports...inspections and admin items
3. I would recommend you replace all embedded macros with VBA
Thanks. What is the screen resolution of the tablet? The target here is our 20" 1680x1050 monitors.

You are right that I removed all other forms as I didn't think they were necessary, and in addition the forum software was barking at me that my upload was too large. I am working on converting some of the remaining macros, but there are a couple that will probably stay, such as on the Run Query button.
 

isladogs

MVP / VIP
Local time
Today, 18:21
Joined
Jan 14, 2017
Messages
18,216
I edited my original post after you read it! See point 4
The 12" tablet resolution is 1920*1080 but I suggest you test in a variety of resolutions/screen sizes and/or use automatic form resizing

EDIT
I just tested in your target resolution. Even more text was cut off
 

zeroaccess

Active member
Local time
Today, 12:21
Joined
Jan 30, 2020
Messages
671
I edited my original post after you read it! See point 4
The 12" tablet resolution is 1920*1080 but I suggest you test in a variety of resolutions/screen sizes and/or use automatic form resizing

EDIT
I just tested in your target resolution. Even more text was cut off
The comment is temporary :)

It's interesting that you're seeing things differently than me. I don't have any issues with things being cut off here. The user environment is standardized but I am watching this closely.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:21
Joined
Oct 29, 2018
Messages
21,469
Attached for your evaluation.

Utilities needs to be cleaned up some more but you can see how my menu works.
Hi. I don't know how to test your file, but I made the changes to the HideAllMenus function to skip the first Select Case block. Could you please tell us if it gives you an error? Thanks!
 

Attachments

  • ZA Menu Demo.zip
    735.2 KB · Views: 100

isladogs

MVP / VIP
Local time
Today, 18:21
Joined
Jan 14, 2017
Messages
18,216
Display issues are common when users have different screen sizes, form factors and resolutions.
That's why I use automatic form resizing on all my commercial apps and many of my example apps as well.

You may be pleased to know that no text was cut off on my 22" desktop with 1680*1050 resolution
 

zeroaccess

Active member
Local time
Today, 12:21
Joined
Jan 30, 2020
Messages
671
Hi. I don't know how to test your file, but I made the changes to the HideAllMenus function to skip the first Select Case block. Could you please tell us if it gives you an error? Thanks!
Strange! I tried the exact same thing and I got errors, but not in your version.

But I figured out why - there was a menu spacer (empty cell) that accidentally picked up a tag value at some point. That was throwing the error since empty cells can't have tags. I removed it right before attaching here. Thanks for testing.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:21
Joined
Oct 29, 2018
Messages
21,469
Strange! I tried the exact same thing and I got errors, but not in your version.

But I figured out why - there was a menu spacer (empty cell) that accidentally picked up a tag value at some point. That was throwing the error since empty cells can't have tags. I removed it right before attaching here. Thanks for testing.
Okay. That, at least, got us both on the same page. Thanks for the clarification. Cheers!
 

zeroaccess

Active member
Local time
Today, 12:21
Joined
Jan 30, 2020
Messages
671
Display issues are common when users have different screen sizes, form factors and resolutions.
That's why I use automatic form resizing on all my commercial apps and many of my example apps as well.

You may be pleased to know that no text was cut off on my 22" desktop with 1680*1050 resolution
Thanks. Are you referring to any of the following options:

Section:
Auto Height
Can Grow
Can Shrink

Format:
Auto Resize

I think I can simulate what you are seeing by sizing down my Access window before clicking on Reports or Admin. The above settings don't seem to have any effect on the issue, though.
 

zeroaccess

Active member
Local time
Today, 12:21
Joined
Jan 30, 2020
Messages
671
Okay. That, at least, got us both on the same page. Thanks for the clarification. Cheers!
I think you have shown that I can skip the check for control type, though.

Still, I am glad that I was shown how to do that as that could be useful elsewhere, you never know.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:21
Joined
Oct 29, 2018
Messages
21,469
I think you have shown that I can skip the check for control type, though.

Still, I am glad that I was shown how to do that as that could be useful elsewhere, you never know.
Hi. We're all happy to assist. Good luck with your project.
 

isladogs

MVP / VIP
Local time
Today, 18:21
Joined
Jan 14, 2017
Messages
18,216
Thanks. Are you referring to any of the following options:

Section:
Auto Height
Can Grow
Can Shrink

Format:
Auto Resize

I think I can simulate what you are seeing by sizing down my Access window before clicking on Reports or Admin. The above settings don't seem to have any effect on the issue, though.


No. I'm talking about resizing forms and their controls automatically to fit end users screens no matters what size, shape or resolution.
See my extended article Automatic Form Resizing Tutorial
 

jdraw

Super Moderator
Staff member
Local time
Today, 13:21
Joined
Jan 23, 2006
Messages
15,379
There is an older thread here that may have some related info.
 

zeroaccess

Active member
Local time
Today, 12:21
Joined
Jan 30, 2020
Messages
671
Thanks. I don't have a UA account, but I have thought about this and designed everything to fit well within the screen space we have at work.

I will refer back to this if I run into any issues.

EDIT: it sounds like that code is resizing controls and forms? If so, I don't agree with that approach. That is not how Microsoft designs any of their programs. You want everything to stay the same size. If someone upgrades their monitor, extra screen space should be extra real estate and not just larger everything. Of course I could be misinterpreting as again I can not download that demo.
 

Users who are viewing this thread

Top Bottom