Solved Class Module to Drag/Drop Multiple Labels on Form (1 Viewer)

MajP

You've got your good things, and you've got mine.
Local time
Today, 07:51
Joined
May 21, 2018
Messages
5,081
This is exactly what I was talking about earlier. It works for our needs; although in our case, we were using it for Award Certificates.
@theDBguy,
How do you determine the measurements? Do you just redesign and record the measurements or are you actually measuring a paper report?
I think what the OP has could work as an interface to automating this process. The user could move things around and could even add resizing of controls. Then you could hit a button and save a record with all the measurements. This would allow a user to build and store a report without design without having to go through trying to get the measurements.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:51
Joined
Oct 29, 2018
Messages
15,542
@theDBguy,
How do you determine the measurements? Do you just redesign and record the measurements or are you actually measuring a paper report?
I think what the OP has could work as an interface to automating this process. The user could move things around and could even add resizing of controls. Then you could hit a button and save a record with all the measurements. This would allow a user to build and store a report without design without having to go through trying to get the measurements.
Hi. I don't have the project in question in front of me right now; but if I remember correctly, the user opens a Form that represents the labels on a Report. The user can drag and drop the labels around the form or double-click on each label and enter a value for X & Y coordinates in inches (as offsets to the left and top margins, I think). When the users close the Form or select a different certificate to adjust, the settings changes are saved to a table. When the user opens the Report, the applicable settings are read from that table and the measurements are converted into Twips.

The user can add new certificates, which means simply adding a new record to the table. As for the labels, I think I added about 20 labels on the Form and Report, to give them an option to display 1 to 20 data points on the Awards Certificate. If they need more than that, we'll need to update the Form and Report design to add more labels, but the Settings Table simply needs new records for the additional labels.

So, to answer the question about measuring the report, I don't do any. The user tweaks the Form by moving the labels on the Form and then previewing or printing a sample report. Each settings changes is maintained in the table, so they only need to do this process once.

Does that help?
 
Last edited:

MajP

You've got your good things, and you've got mine.
Local time
Today, 07:51
Joined
May 21, 2018
Messages
5,081
Does that help?
Thanks. Yes that is what I was thinking. Use a form to customize the report and save the design settings to a table.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 07:51
Joined
May 21, 2018
Messages
5,081
@G37Sam,
You can easily add in resizing the controls as well. I added the -, + keys to the left of the backspace.
Case 187 ' +
Me.DragTextBox.Width = Me.DragTextBox.Width + shiftSpeed
Case 189 ' -
Me.DragTextBox.Width = Me.DragTextBox.Width - shiftSpeed
End Select
Could pick two other controls for the height.
 

Attachments

  • DragTextBox4.accdb
    468 KB · Views: 23

G37Sam

Registered User.
Local time
Today, 15:51
Joined
Apr 23, 2008
Messages
456
Yes - I am only doing this with one report, thats the whole point :)

The x's and y's of each field change dynamically depending on the user-defined cheque template. I will upload the final database once done for your reference and comments.
 

G37Sam

Registered User.
Local time
Today, 15:51
Joined
Apr 23, 2008
Messages
456
Database attached for reference and comments
 

Attachments

  • Cheque Printer v1.2 - Copy.accdb
    2.9 MB · Views: 26

arnelgp

once i caught a fish alive...
Local time
Today, 19:51
Joined
May 7, 2009
Messages
13,202
chequeProfile, right.
how is it saving the profile?
i select bank1 and start re-positioning the labels.
i switch to bank2 and go back to bank1, my edit is lost.

there is no Drag feature.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 07:51
Joined
May 21, 2018
Messages
5,081

G37Sam

Registered User.
Local time
Today, 15:51
Joined
Apr 23, 2008
Messages
456
next to Cheque Profile, theres a folder icon that opens the profile editor

You will need to hold CTRL button to drag, it was misbehaving without CTRL
 

jdraw

Super Moderator
Staff member
Local time
Today, 07:51
Joined
Jan 23, 2006
Messages
13,760
Not specific to your drag and drop, but developing a class module to work with controls on forms.
This video on Navigating Forms with Events is from the AccessUserGroups Pacific region presented by Mike Wolfe May 2021.
Details and sample code in the notes section of the video including link to Mike's site and related info.
Indirect thanks to Crystal.
 
Last edited:

arnelgp

once i caught a fish alive...
Local time
Today, 19:51
Joined
May 7, 2009
Messages
13,202
drag work, but without Visual clues it's hard.
you only get a sudden message when you cross
pass the border.

here is a sample of "drag" that you can see
where are you dragging.
 

Attachments

  • sampleLabelDragClass.accdb
    436 KB · Views: 22

arnelgp

once i caught a fish alive...
Local time
Today, 19:51
Joined
May 7, 2009
Messages
13,202
majp,if you can extend your class or mine.
the idea is prevent "collision/overlay" with other
controls on the form.
the label being drag must not be placed
on top/bottom of other controls and labels?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 07:51
Joined
May 21, 2018
Messages
5,081
majp,if you can extend your class
It is not really my class since I only demonstrated how to instantiate it, the code was from the OP.
However, it does not really seem like that big of an issue IMO. Your demo provides a very useable interface. If can drag the small control through the big control it provides enough visual clue to be obvious where the smaller control is.
I guess you could add an optional argument to "allow stacking" with the default set to false. Then give the user the option to allow them to stack controls on top of another or not. If allow stacking = false on the mouse up you could loop all form controls and somehow determine if any positions overlap (I am not sure how to do that easily). Then if an overlap return to original m_x, m_y.
 

arnelgp

once i caught a fish alive...
Local time
Today, 19:51
Joined
May 7, 2009
Messages
13,202
updated class with "Collision" detection.
the labels will not "overlap" each other.
 

Attachments

  • sampleLabelDragClass.accdb
    960 KB · Views: 22

MajP

You've got your good things, and you've got mine.
Local time
Today, 07:51
Joined
May 21, 2018
Messages
5,081
@arnelgp. That is a much better solution. Hopefully the OP comes back. The "stacking" check is simpler than I thought it would be.
 

Users who are viewing this thread

Top Bottom