Sort Button Order on form (the actual buttons themselves) (1 Viewer)

GaryPanic

Smoke me a Kipper,Skipper
Local time
Today, 03:39
Joined
Nov 8, 2005
Messages
3,294
Hi guys been a while and before i go down this route I have thought of - thought it worth asking the question ..

Product A =
a form with 8 buttons on them - each button opens up a form /table and I do stuff in each of these of these 8 forms tables - each doing something different

Product B= may only need 5 (as an example) and let say the need "form" 1 from above and 3 4,6 and 7

is there away only these buttons show ( easy - ) but actuall "list themselves "
so Product A buttons in this order1-8 and Product B= 1,3,4,6,7 with the same spacing between (not 1 blank space for 2 , 3 visible and 4 and then blank space for 5 and 8)

I hope makes sense
 

mike60smart

Registered User.
Local time
Today, 11:39
Joined
Aug 6, 2017
Messages
1,904
Hi guys been a while and before i go down this route I have thought of - thought it worth asking the question ..

Product A =
a form with 8 buttons on them - each button opens up a form /table and I do stuff in each of these of these 8 forms tables - each doing something different

Product B= may only need 5 (as an example) and let say the need "form" 1 from above and 3 4,6 and 7

is there away only these buttons show ( easy - ) but actuall "list themselves "
so Product A buttons in this order1-8 and Product B= 1,3,4,6,7 with the same spacing between (not 1 blank space for 2 , 3 visible and 4 and then blank space for 5 and 8)

I hope makes sense
Hi

Just set the Tab Order on the Form
 

SHANEMAC51

Active member
Local time
Today, 13:39
Joined
Jan 28, 2022
Messages
310
Product A =
a form with 8 buttons on them - each button opens up a form /table and I do stuff in each of these of these 8 forms tables - each doing something different
I would probably use a list instead of buttons, which I would update depending on the necessary processing

or even a table with 4 fields (id, product type, check mark for completion, name of the form to open)
 

GaryPanic

Smoke me a Kipper,Skipper
Local time
Today, 03:39
Joined
Nov 8, 2005
Messages
3,294
interesting .... i have not started this yet
- ok I like the idea of a "list" - double click etc... - (it creates a another problem for me - but I can deal with this easy enough-
Tab order hmmm ? would the buttons not remain in the order they were placed on the form

thinking out loud - would a continous form not work ? so form 1 has a number assigned to 1 (of course) 2-8 then if I select product "B" it would then with a bit of tweaking only load 1,3,4,6&7.. haven't thought it all the way through.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 11:39
Joined
Jul 9, 2003
Messages
16,282
a form with 8 buttons on them

That description of what you want, exactly describes the "Switchboard" provided by Microsoft Access. I would suggest you have a look at that.

Further, the latest version of the switchboard is run by macros and in my opinion is a backward step. The original VBA driven version is much better. I understand that @Pat Hartman has a Very nice example of the VBA switchboard, which I am sure she will post for you, if express an interest...
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 11:39
Joined
Jul 9, 2003
Messages
16,282
each button opens up a form /table

You do not allow you users into the tables directly. What you should do is open another form, and in the form have the records you want to show from the table, in a subform, in datasheet view or continuous form view.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 11:39
Joined
Jul 9, 2003
Messages
16,282
I have a product called the "Nifty Switchboard Builder". You are welcome to a free copy. Send me a pm if you do ...

 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 11:39
Joined
Jul 9, 2003
Messages
16,282
Here is a video of the Microsoft switchboard being set up:-


I just realised, that to change the order the buttons appear in, if you use the Microsoft switchboard you are going to need to amend the VBA code.
 

GaryPanic

Smoke me a Kipper,Skipper
Local time
Today, 03:39
Joined
Nov 8, 2005
Messages
3,294
not sure if this does what I wanted it to do - but certainly is very clever -

and your explaination was very clear - (I understood it - and that is saying soemthing - as i am not the brightest )

I think i will need coding - and have it half sorted in my head with
some if statements

If product = x then button 1 visible and then change the location of the button and the same with all 8 buttons
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 11:39
Joined
Jul 9, 2003
Messages
16,282
change the location of the button

A different approach, don't move the buttons, just change the text on the buttons.

That's how the Switchboard works, which is why I thought it would be a good starting out idea.
 

GaryPanic

Smoke me a Kipper,Skipper
Local time
Today, 03:39
Joined
Nov 8, 2005
Messages
3,294
Hmm - interesting various routes - I will "ponder" on this - no urgency in what i was trying to achieve - just planning it out, so when I decide to actually do it I willb e in a better postion to understand

all thoughts on this have been welcome and constructive

Big thanks to all

Gary (less panic)
 

June7

AWF VIP
Local time
Today, 02:39
Joined
Mar 9, 2014
Messages
5,470
If change button caption, code might no longer coincide.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 03:39
Joined
Oct 29, 2018
Messages
21,471
I have used the continuous form approach in the past.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 06:39
Joined
Feb 19, 2002
Messages
43,266
None of the switchboard suggestions will work to solve your problem. You need to create a table that defines what you want. So for typeA, it lists 1,2,5 and for TypeB, it lists 2,3,4. This list will be displayed in a subform or list box. You can make the outer shell of the subform disappear but probably the listbox will be simpler for you. The rowsource for the listbox will be

select RecTypeID, FormDesc, FormName
From YourTable
Order by SeqNum
Where RecType = Forms!yourform!cboRecType;

In the afterUpdate event of cboRecType, requery the listbox. For an existing form, the listbox should just work.

Then in the double click event of the listbox, open the selected form using the OpenForm method and the value in FormName.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 05:39
Joined
Feb 28, 2001
Messages
27,179
If you are talking about dynamic button placement, I did something like this some years ago. Due to legal issues, I couldn't keep the code and even if I had it, there would be a risk of liability if I published it. But I can describe what I did.

I set aside an area on my form where my buttons would go. I took great pains to assure that my buttons were of fixed height and it happened that they were of fixed width as well. Then I had a set of variables in the declaration area of the form that recorded the .TOP, .LEFT, .HEIGHT, and .WIDTH of the set-aside "button display" area and the .TOP and .LEFT of the next button to be placed.

Every time the form .CURRENT event fired, I reset the "recent" TOP and LEFT to the set-aside TOP and LEFT. Then, because there were not that many buttons per form, I just linearly called a routine once for each button, with a parameter for the next button to place (by ref) and the state of the button for this situation (by val). This was a rare case where I intentionally allowed a side-effect, because the six variables were used "globally" from within the form's class declaration area. I did that for debugging purposes because I decided to NOT make it a separate class. (Didn't have the time for it.)

The subroutine would look at the button's state code. If the state was "button not used" I disabled the button, made it invisible, and moved it somewhere innocuous. Disabled, invisible buttons CAN overlap with no bad results, so all unused buttons usually ended up sitting under the HELP button.

If the state was "button in use" I enabled the button, made it visible, and moved it to the appropriate place indicated by the "recent" TOP and LEFT. Then I looked at the button's .WIDTH and .HEIGHT and updated the "recent" TOP and LEFT for the next button to use (or not).

I did learn one lesson about moving buttons around. You move and place buttons in units of TWIPS (1440/inch). NEVER make the RIGHT edge of one button exactly adjacent to the LEFT edge of another button, and ditto for TOP and BOTTOM edges. Add 1 twip between them because at unpredictable different screen sizes, you can get a video "flutter" anomaly if the actual screen size isn't an even multiplier of units of twips. With that 1 extra twip between them, the anomaly goes away.

If the user did something to change the situation (which could happen without doing a SAVE), I would recall the button-control routine with updated "in use" flags. The buttons I was using would never ALL be enabled at once. Things like SAVE, NEW, UNDO, REMOVE, EXIT (form), HELP, FILE REPORT... In this application, if the form wasn't dirty, SAVE and UNDO were not in use. If it WAS dirty, NEW, REMOVE, and EXIT could not be used. HELP and FILE REPORT were always valid. A very few special-case buttons also were in the mix for some forms. The decisions to change the buttons in my app were made after each control's .LOSTFOCUS routine, which also changed highlighting of the control that just lost focus. It saved the OTHER part of highlighting for the control that was going to run .GOTFOCUS as soon as .LOSTFOCUS did an EXIT SUB.

It was a bit tedious at first, but once I got it right, it was pretty smooth and quick too. The only trick is if I had so many special buttons that I had to overflow them into the next row on the form. But if the buttons were uniform in height as well as width, they fit nicely. And yes, in this case, I had the .BEFOREUPDATE event trapped so that you could only save a record with the SAVE button. You could not navigate because I turned those buttons off if the form was dirty. Couldn't exit with a dirty form either.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 06:39
Joined
Feb 19, 2002
Messages
43,266
I forgot to mention that if you use the subform method, you can use a continuous form with actual buttons. So if you hide the frame of the subform and size it just right, it will show only the buttons and nothing else.

There is no code involved to hide/show buttons. The criteria in the query is used.
 

Users who are viewing this thread

Top Bottom