Full Version: Click & Drag
UtterAccess Forums > Microsoft® Access > Access Forms
While reviewing a database I have written with my wife for our budget, she asked if we could "Click & Drag" on data and move it to other fields on the form. This data was not only values such as dollar amounts but whole fields from one budget group to another.
Well as an experienced coder this had me stumped, I have never tried to do this before so has anyone else managed to copy the explorer feature of "Click & Drag" ?
You can't click and drag like that in Access, but you can highlight it, CTRL-C to copy, then click where you want it and CTRL-V to paste
Thanks Crystal,
I had a feeling you couldn't do it. I thought someone might have 'coded' a copy of it. I am aware of the 'ole copy & paste method thanks, she just wanted to do it in one step.
don't blame her wink.gif
You're welcome and cheers back o!
Hi Mick and Crystal,
read this thread and thought it would be fun to try and hack a solution.
Oattach a small db with one form, and a couple of class modules.
The premise is very simple.
In the OnLoad of the form you add a new Class clsDragNDropForm.
Then add the controls to drag and drop from. You can specify whether a textbox is both draggable and droppable, or only either draggable or droppable.
The form needs a hidden label which will show the 'drag text' as it's being dragged.
This is a quick and dirty hack that could surely use some improvement. It only works for textboxes and only on the same form. I'm sure there is some far more efficient way to do this using API's.
I hope it gives you a start point if you fancy playing with it further.
only made this using unbound textboxes, so any issues/situations about whether a bound field can be changed or only be filled with a specific datatype will have to be handled.
Hi Cheecky,
Thanks -- I am anxious to see how this works -- but right now, it errors out when loading the form
object doesn't support this property or method
Private Sub cl_frm_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim b As Byte
'   If mouse is not over a drop field then we don't want to drop anything
    With m_colDrag
        For b = 1 To m_colDrag.Count
           [color="red"] .Item(b).DropField = ""[/color]
        Next b
    End With
End Sub

can you post a screen shot of your references?
btw, this happens on b=1
Oops - I removed the property!
ive me a minute and I'll post the correct version
thanks thanks.gif

Can't wait to see this! I looked at the code and it is very clever...
Worked perfectly on my Access 00. Neat piece of code.
Hi Crystal,

Sorry for the delay. It was a strange error that didn't show up in my compile (???)

Ore-worked the logic slightly of the textbox mousemove event to handle clearing the dropfield when not over a textbox. So, no need for the form to have a mousemove event.

Please see this revised version



Alton, I'm glad it works for you - perhaps try the second version too to see if it works better.


*********** Please do not use the attachment in this post - use the one in the post below *************
Edited by: cheekybuddha on Wed Dec 14 12:24:02 EST 2005.
OK, sorry to bombard you with so many different versions.
Since the reference to the actual calling form isn't needed (only the reference to the class is required) I tidied up a bit further and removed the object from clsDragNDropForm, and used the textboxes' Parent property to refer to the form in clsDragNDropTextBox
So, here you go!
Hi all,
I have just realised that I did not add any cleanup code the the form 'frmClickTest'.
If you use any of the examples I posted please add the following code to the form's Unload event:
Private Sub Form_Unload(Cancel As Integer)
    If Not myDragNDrop Is Nothing Then Set myDragNDrop = Nothing
End Sub

ow! thanks for that!
will have a bit of a play myself now
MickH o!
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.