Solved Smooth expand / collaps height width of subform.

Ihk

Member
Local time
Today, 23:59
Joined
Apr 7, 2020
Messages
280
I have subform on Mainform. Normally subform on the main form is far right and looks like a thin line (collapsed completely).
There is button on Mainform, this button can be for any thing like add edit etc. But basically this button is only expanding the form. I know there are many ways, smooth sliding, hiding etc etc.
But I am using a very simple trick (no modules, not many lines of code etc) . On button click
for expanding
Code:
Form2.Height = 2880
Form2.Width = 6075
for collapsing, this can be a click on Main form anywhere
Code:
Form2.Height = 300
Form2.Width = 6075
Everything is fine upto here ------------
Just I have question here, is there way to control the speed of height widh increase decrease, which may make it smooth appearing or disappearing.
I tried adding like this along with above code but did not work.
Code:
Option Compare Database
Option Explicit
Const iResizeInterval   As Long = 100
Thank you
 
Check the attached database. Click the button on left.
Change the numbers for different speed.


Edit: oops too late.
 

Attachments

Check the attached database. Click the button on left.
Change the numbers for different speed.


Edit: oops too late.
Thank you
This button gives me following error
1659531491206.png
 
Thank you
This button gives me following error
View attachment 102211

1- If you are using a 32 bit version of Access change this line
Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
to
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

2- if still you receive error, I'm using a non-English version of Access.
Copy the module and the code in on_Click event of the button to your database and test it three.
 
change the 50 in the code (bigger value means slower expand/collapse).
 

Attachments

  • Like
Reactions: Ihk
1- If you are using a 32 bit version of Access change this line
Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
to
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

2- if still you receive error, I'm using a non-English version of Access.
Copy the module and the code in on_Click event of the button to your database and test it three.
I am using 64bit, 2021 version of office. I tried point 2. still error is there.
 
I have attached sample / demo db.
It has two forms.
Right side subform
Left side subform (streched across right top down), this form has problem. which is mention on Main form.
click on form body to collaps.
 

Attachments

change the 50 in the code (bigger value means slower expand/collapse).
Thank you very much.
I will check this later today, if also works
if I want subform for example (Full right side, streched across top down), how it shows on different screen size.
 
As picture below.. I am trying to achieve..
Assume this redboder picture is the main form, and it has many subforms which will appear on right but stretched across top down as shown a white form on top of main form. User wants to add record, this form show up by sliding twoward left, and then goes away....
1659534272330.png
 
Last edited:
change the 50 in the code (bigger value means slower expand/collapse).
@arnelgp , thank you very much. I adjusted it in my case, it is super perfect and speed is adjustable.
But I have one question here, How can I change the movement direction?
In this case it is from left to right. But in my case mostly I want right to left.
I tried this by adjusting the form on most right side, but still on expand it can clearly be seen sliding from left to right.
 
Last edited:
Just to share a link, if someone comes on this thread,
A related link to this (sliding of subform) is below - demo db is also there. The only difference is, it has button inside subform.
where it has been shown horizontal and verticle sliding of form. Whatever someone likes.
MS Access - Sliding/Shutter Subform Example | DEVelopers HUT (devhut.net)

In above given Post#6 by @arnelgp is short code, understandable and button performing action is on Main form, which is more practical in my case. The only thing to figure out in this case is movement direction for subform. Hope this will be figured out too.
 

Users who are viewing this thread

Back
Top Bottom