Solved Simple VBA code to change form of a subform programmatically .. (1 Viewer)

Pat Hartman

Super Moderator
Staff member
Local time
Today, 15:10
Joined
Feb 19, 2002
Messages
43,279
Sorry, maybe I just misread what you said.
The comment was subtle and I didn't expand on it. I don't know for certain that buttons won't work. It is just not obvious how to make them work and I didn't have the time to spend on the task. Give it a shot.
 

sjs94704

Member
Local time
Today, 12:10
Joined
May 7, 2013
Messages
41
The comment was subtle and I didn't expand on it. I don't know for certain that buttons won't work. It is just not obvious how to make them work and I didn't have the time to spend on the task. Give it a shot.
OK, well I do remember from a previous experience that the security issue was quite cumbersome, but in that case we were opening and closing entire forms and the list if IF statements that we ended up having to cover all the various roles got very long! We probably could have done a much better job by breaking redundant things up into smaller routines, but it is what it is!
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 15:10
Joined
Feb 19, 2002
Messages
43,279
I didn't know we were talking about security. I thought we were just talking about a way to format a switchboard/menu as a navigation pane but use a subform to control the buttons rather than hard coding them.

For your own sanity, security settings should NEVER be hard coded. Always tablize them. If you need an example of a simple way to do that, look at the switchboard with securities sample database. Some of the switchboards are the same as in the unsecured version but not all.

 

sjs94704

Member
Local time
Today, 12:10
Joined
May 7, 2013
Messages
41
I didn't know we were talking about security. I thought we were just talking about a way to format a switchboard/menu as a navigation pane but use a subform to control the buttons rather than hard coding them.

For your own sanity, security settings should NEVER be hard coded. Always tablize them. If you need an example of a simple way to do that, look at the switchboard with securities sample database. Some of the switchboards are the same as in the unsecured version but not all.

Thanks, Pat. I appreciate the referral. I have book marked the security database thread and will take a closer look.
 

murphybridget

Member
Local time
Tomorrow, 03:10
Joined
Dec 5, 2023
Messages
64
Thanks Pat, I will definitely develop something around this whole idea. I was getting ready to do an accordion style menu system links or buttons on the left side and you got me thinking about the possibility of making adding more future buttons in a manor that makes the whole process a lot easier (flexible). I did some preliminary tests using some simple unicode symbols and they display in the table just fine so they should easily display in the button menu. So that's what I was hoping for.

I just added two more columns to your tblButtons to hold the decimal value of the unicode values (DecVal_1 and DecVal_2). Then using a query to combine them together with the text of the button creates a nice looking button. I will need to do a lot more testing to see what's possible and what's not, but so far it has potential.
Sounds like a clever approach to enhance the visual appeal of the buttons.
 

Mike Krailo

Well-known member
Local time
Today, 15:10
Joined
Mar 28, 2020
Messages
1,044
It looks like the solution to binding captions to buttons from tables into continuous forms has been solved using the paint event for the detail section of the continuous form. This idea was from another thread about manipulating the visibility of a command button in a continuous form which is not possible. But each buttons caption can be different according to a table or a field in the continuous form by using that On Paint event. Didn't think it was possible until today.

Code:
Private Sub Detail_Paint()
   Me.Option1.Caption = Me.ItemText
End Sub


1705445355174.png
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 15:10
Joined
Feb 19, 2002
Messages
43,279
That's pretty amazing. Thanks for following through on that idea.

Mike, can you upload your version of the form so I don't have to figure out the details and I'll add it into my switchboard samples? Thanks.
 

Mike Krailo

Well-known member
Local time
Today, 15:10
Joined
Mar 28, 2020
Messages
1,044
I'll give you what I have which isn't much. I'm really just toying around with the idea after having learned this technique. There is currently a bug that causes all the buttons to turn into "Exit Application" buttons (continuous navigation form). Not sure why yet. I see that the paint event is firing four times the moment I hover over one of the buttons which was not expected. When the bug doesn't trigger, it seems to work. So there should be a path forward with this.
 

Attachments

  • AccessSwitchboardONLY_20240116.zip
    398.7 KB · Views: 33

murphybridget

Member
Local time
Tomorrow, 03:10
Joined
Dec 5, 2023
Messages
64
I'll give you what I have which isn't much. I'm really just toying around with the idea after having learned this technique. There is currently a bug that causes all the buttons to turn into "Exit Application" buttons (continuous navigation form). Not sure why yet. I see that the paint event is firing four times the moment I hover over one of the buttons which was not expected. When the bug doesn't trigger, it seems to work. So there should be a path forward with this.
Thank you for sharing. Though I may not have any direct use for the file, I truly appreciate everyone's desire to help. Who knows I might this in the future.
 
Last edited:

Pat Hartman

Super Moderator
Staff member
Local time
Today, 15:10
Joined
Feb 19, 2002
Messages
43,279
Thanks. I'm busy for a week or two but will get to it.
 

Mike Krailo

Well-known member
Local time
Today, 15:10
Joined
Mar 28, 2020
Messages
1,044
Thanks. I'm busy for a week or two but will get to it.
I got it working better now, but there is still a small anomaly that causes the buttons caption to change to the value of the button below it after clicking the button. It's nothing major, but working around this event is kind of tricky.
 

Attachments

  • AccessSwitchboardONLY_20240117.zip
    390.6 KB · Views: 30

Pat Hartman

Super Moderator
Staff member
Local time
Today, 15:10
Joined
Feb 19, 2002
Messages
43,279
That's the kind of stuff I was running into when I built the sample form and since I didn't need the functionality, I didn't have time to futz with it.
 

Users who are viewing this thread

Top Bottom