Bring To Front & Send Back Properties using VBA (1 Viewer)

gstylianou

Registered User.
Local time
Today, 03:54
Joined
Dec 16, 2013
Messages
357
Good Evening

In the database I am attaching there is the form Form1 on which there are several fields with hours. The request is to be able to define the Properties Bring To Front & Send Back via VBA when and if I click on the Text0 field.

I am providing an example of the request and I will appreciate your help.

Thanks in advance
 

Attachments

  • MyTest.accdb
    504 KB · Views: 45

gstylianou

Registered User.
Local time
Today, 03:54
Joined
Dec 16, 2013
Messages
357
Any help?

Thanks
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 17:54
Joined
Aug 30, 2003
Messages
36,126
Did you try the code from the link in post 2?
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 17:54
Joined
Aug 30, 2003
Messages
36,126
What is your code now? Do you get an error, or the results aren't as desired? If the second, what are you expecting to happen vs what does happen?
 

isladogs

MVP / VIP
Local time
Today, 01:54
Joined
Jan 14, 2017
Messages
18,235
Although not mentioned in this thread, your example app mentions another requirement which is to enlarge the height of the clicked control.
Selecting a textbox will automatically bring it to the front.
As you day you want the height of Text) to be 4x larger when clicked, you don't actually need to use bring to front / send to back. Try this

Code:
Private Sub Text0_Click()
    Me.Text0.Height = 4 * Me.Text1.Height
End Sub

Private Sub Text0_LostFocus()
    Me.Text0.Height = Me.Text1.Height
End Sub

When clicked, Text0 will then cover Text1/2/3 as well
By comparing with Text1.Height, it ensures that repeated clicks don't cause it to get any taller
The lost focus event ensures it goes back to the default height
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 08:54
Joined
May 7, 2009
Messages
19,245
you can also use Conditional Format on the textbox to change its color.
and also code to change it's border, so the textbox that has focus is highlighted ("effect").
 

Attachments

  • MyTest.accdb
    960 KB · Views: 42

spaLOGICng

Member
Local time
Yesterday, 17:54
Joined
Jul 27, 2012
Messages
127
Why not just set the Visible Property of the Controls to True or False.

I only use bring to front of send back functions in design mode. And now, with the new stacking and tabular features and anchoring, new since the 2007 version anyway, I never use them.

In one of my lastest apps, where it was more efficient to have three combo boxes that filtered on the same column, where each combo box had different columns in them, rather than having one combo box and changing the row source in VBA... I simply laid all three combo boxes on top of each other but only one would be visible at a given time. I had a combo box to the left of it where the user would select a search type, and based on that search type the respective combo box to the right of it would be made visible in the other two would be made invisible.

Hope the idea helps.
 

gstylianou

Registered User.
Local time
Today, 03:54
Joined
Dec 16, 2013
Messages
357
Although not mentioned in this thread, your example app mentions another requirement which is to enlarge the height of the clicked control.
Selecting a textbox will automatically bring it to the front.
As you day you want the height of Text) to be 4x larger when clicked, you don't actually need to use bring to front / send to back. Try this

Code:
Private Sub Text0_Click()
    Me.Text0.Height = 4 * Me.Text1.Height
End Sub

Private Sub Text0_LostFocus()
    Me.Text0.Height = Me.Text1.Height
End Sub

When clicked, Text0 will then cover Text1/2/3 as well
By comparing with Text1.Height, it ensures that repeated clicks don't cause it to get any taller
The lost focus event ensures it goes back to the default height

isladogs could you please modify my example exactly on your code?​

Thanks
 

gstylianou

Registered User.
Local time
Today, 03:54
Joined
Dec 16, 2013
Messages
357
Basically what I'm trying to do is one dynamic calendar similar to Google Calendar which after defining for an appointment ex. from 08:00 to 12:00 can do the following:

1. Show the title or details only into the first engaged hour (08:00) for the appointment
2. To Colored all engaged hours (Border Line) with color so that at first glance someone understands that it is Reserved from 08:00 – 12:00
3. And color all the fields with some color (Background Color)

Any help to accomplish the above request is welcome and I am committed to sharing it here for use by anyone interested
 

isladogs

MVP / VIP
Local time
Today, 01:54
Joined
Jan 14, 2017
Messages
18,235
Attached is your app with the code from post #7 added
It does exactly what you asked for originally - I've not taken into account what you've added in post #11 as that wasn't mentioned previously

If you want every textbox control to expand to 4x the height when clicked you would need to add similar code for each textbox which would be VERY tedious. Alternatively a generic function could be created and called when any textbox is clicked

But there is a simpler solution that is less work and may do what you need - use the click event to open a zoom box.
I've done this for Text1

Code:
Private Sub Text1_Click()
    DoCmd.RunCommand acCmdZoomBox
End Sub
 

Attachments

  • MyTest_CR.zip
    62.8 KB · Views: 34
Last edited:

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 17:54
Joined
Aug 30, 2003
Messages
36,126
Basically what I'm trying to do is one dynamic calendar similar to Google Calendar which after defining for an appointment ex. from 08:00 to 12:00 can do the following:

1. Show the title or details only into the first engaged hour (08:00) for the appointment
2. To Colored all engaged hours (Border Line) with color so that at first glance someone understands that it is Reserved from 08:00 – 12:00
3. And color all the fields with some color (Background Color)

Any help to accomplish the above request is welcome and I am committed to sharing it here for use by anyone interested

That doesn't seem at all like the original request. I did something along these lines a long time ago to display limousine reservations on a given day. If memory serves I used a brute force method of populating a temp table with reservations within a loop. I'm sure there's a better way, I did this many many years ago. Colors represent different vehicle types, the start time and reservation number are at the top of each, customer names at the bottom.

1708372946853.png
 

gstylianou

Registered User.
Local time
Today, 03:54
Joined
Dec 16, 2013
Messages
357
That doesn't seem at all like the original request. I did something along these lines a long time ago to display limousine reservations on a given day. If memory serves I used a brute force method of populating a temp table with reservations within a loop. I'm sure there's a better way, I did this many many years ago. Colors represent different vehicle types, the start time and reservation number are at the top of each, customer names at the bottom.

View attachment 112659

pbaldy Good morning,

This is exactly what im trying to do..! Could you please give me a hand to do that?

Thanks​

 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 17:54
Joined
Aug 30, 2003
Messages
36,126
Like I said, mine was a brute force attack. I suspect it could be done much easier with a Gantt chart, but I have no experience with them. Search on that and see what you find.
 

isladogs

MVP / VIP
Local time
Today, 01:54
Joined
Jan 14, 2017
Messages
18,235
The best interactive Gantt charts I have ever seen are those Aleksander Wojtasz demonstrated to the Access Europe User Group last summer.

 

Users who are viewing this thread

Top Bottom