Solved Gap Buttons (1 Viewer)

Lampje

Member
Local time
Today, 17:42
Joined
Jul 20, 2021
Messages
31
Considered Forum,
a number of buttons (Fig 1) can be visible/invisible at will (Fig 2).
With the code I get the result in (Fig 3), but I can't get it as (Fig 4).
Would you like to help me find the right code?

Code:
For x = 1 To 8
    If Me("B" & x).Visible = True Then
        Me("B" & x).Move 16443, (z) + (284 * (x - y)), 284, 284
    Else
        y = y + 1
    End If
Next x




2022-05-05.png
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:42
Joined
May 7, 2009
Messages
19,227
Code:
Dim x As Integer, y As Integer
y = 1
For x = 1 To 8
    If Me("B" & x).Visible = True Then
        'Me("B" & x).Move 16443, (z) + (284 * (x - y)), 284, 284
        'arnelgp
        Me("B" & x).Top = Me("B" & y).Top
        y = y + 1
    'Else
    '    y = y + 1
    End If
Next x
 

Gasman

Enthusiastic Amateur
Local time
Today, 16:42
Joined
Sep 21, 2011
Messages
14,217
I would do the math and just set top.
 
Last edited:

Lampje

Member
Local time
Today, 17:42
Joined
Jul 20, 2021
Messages
31
Best arnelgp a nice routine, unfortunately when I go to the next record it is no longer correct.
There should be 4 buttons visible, but I only see 3.
Fortunately, I saw the light on and by putting z = z + 284 (in my code) in front of the Else, it now works as desired.

In any case, many thanks for the effort taken.
Regards, L
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:42
Joined
May 7, 2009
Messages
19,227
I go to the next record it is no longer correct.
you should call it on the Current event of the form.

edit:
also you need First to make all those 8 controls Visible = False.
then you make the rest visible.
 

Lampje

Member
Local time
Today, 17:42
Joined
Jul 20, 2021
Messages
31
Thanks arnelgp,
but also does not display the correct buttons.
Possibly some things can be disturbed by various Functions that determine whether the Buttons are visible / invisible.
In the way I indicated, it works properly.

Thank you for indicating that it should be at current.
Regards L
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:42
Joined
May 7, 2009
Messages
19,227
the question is how do you set the Visible property to Yes/No?
should be in the current event also.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 16:42
Joined
Jul 9, 2003
Messages
16,269
Very nice interface idea!

I just realised it is reminiscent of the the "Switchboard" supplied by Microsoft.

The original version of the switchboard was controlled by VBA code. It might be of interest to you.

I think @Pat Hartman - has a a copy of the original Switchboard, which she may post for you if you express an interest.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:42
Joined
May 7, 2009
Messages
19,227
here is a demo.
 

Attachments

  • GapButton.accdb
    576 KB · Views: 165

Pat Hartman

Super Moderator
Staff member
Local time
Today, 11:42
Joined
Feb 19, 2002
Messages
43,200
You haven't told us what business problem you are trying to solve. You have asked a technical question that leaves us with no context. That implies that you have decided that hardcoding buttons and using VBA to manipulate them is the ONLY solution. You just don't know how to write the code.

Instead of hardcoding buttons, why not use a subform bound to a table. Criteria controls what records to select. You can format the subform to hide it and all its controls. In a continuous view, you can show buttons. You can make them the size you want and you can surround them with as much white space as you want.
 

GaryPanic

Smoke me a Kipper,Skipper
Local time
Today, 08:42
Joined
Nov 8, 2005
Messages
3,296
lol -- this is the same as I asked a couple of days ago -
- so its interesting to see 1 can it be done (yes) and (2) the benefits of doing it this way ..?
someone suggested somthing different -
I have product 1 needing say 5 buttons opening forms 1,3,,4,5,6 (out of 8 possible options)- sub products)
so I will have
an If statement to open up the forms I need (on click of each button) but if product 1 then button 1 will open form 1 but if button two to open form 3 etc.. and make the unused buttons .visible false

it could get complicated if you had lots of variants - but you can tie the buttons to the product .. i have not started this as i am still digesting is this the best route
 

GaryPanic

Smoke me a Kipper,Skipper
Local time
Today, 08:42
Joined
Nov 8, 2005
Messages
3,296
would be nice to know the answer on this one --
my solutions (I think) is to look at my master table that has buttonsrequired 1-8 (yes/No)
Dlook up up mastertable button 1 true/false if true then visible
all the way through all 8 options
as to listing them beneath each other should be easy (he say's lightly )


Button 1 = location

. left xxx
.top (?) xxx

Button 2 = location button 1 + (top) xxx amount - (I hope with some niffty if statments and dims statements)
but I have not started yet... so might be talkign rubbish
 

SHANEMAC51

Active member
Local time
Today, 18:42
Joined
Jan 28, 2022
Messages
310
Instead of hardcoding buttons, why not use a subform bound to a table. Criteria controls what records to select. You can format the subform to hide it and all its controls.
instead of buttons, you can use a continuous (ribbon) form or even a field with a listbox
, they are easier to manage by setting up access rights and you do not need to recalculate something
 

SHANEMAC51

Active member
Local time
Today, 18:42
Joined
Jan 28, 2022
Messages
310
would be nice to know the answer on this one --
my solutions (I think) is to look at my master table that has buttonsrequired 1-8 (yes/No)
Dlook up up mastertable button 1 true/false if true then visible
all the way through all 8 options
I would probably apply the form to 2 fields: a checkbox and a text, so as not to think further about what action was performed, and if you add a time field, then track the execution, and maybe time the operator's work

I used it often, even before ACCESS
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 16:42
Joined
Jul 9, 2003
Messages
16,269
I think the code from my dynamic check boxes could be adapted to show buttons instead:-

 

GaryPanic

Smoke me a Kipper,Skipper
Local time
Today, 08:42
Joined
Nov 8, 2005
Messages
3,296
cheers to both - I had thought about the continous form route - and in the back of my mind - there's a gremlin - that I cannot quite grab hold of to explain - but I have not started the project yet
Uncle G - as always nice clip - and I get the guts of it - might be a go-er - but I am taking my time to ensure that once I go down a route its not going to create a nightmare somewhere else
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 11:42
Joined
Feb 19, 2002
Messages
43,200
When your buttons are mutually exclusive (only one should be pressed at a time), use an Option group with a case statement rather than separate buttons with separate procedures.
But, as I mentioned earlier, a combo or list box gives you more flexibility and you won't have to modify the form if you need to change the list. Just add/delete items to the table used as the RowSource. The table will contain the name of the form/report to open so there is never any hard-coding of names. No need for If statements, no need for case statements. You just open the form/report selected by the combo/listbox.
 

Users who are viewing this thread

Top Bottom