Simulating drag 'n' drop

J

Jesper F

I was wondering if some kind of drag and drop functionality could be
simulated in Access. I'm trying something along the lines of setting a
global variable on MouseDown and using the variable on MouseUp. Only Access
doesn't "know" where the mouse is when I release the mouse button.
Have any of you programmed some drag'n'drop functionality?

I know Peter's software has an add-in but I'd rather do it myself.
For my particular problem I have a grid of 9x9 commandbuttons simulating
shelves. This is for an inventory system. "Moving" the command buttons
should change the location of the item. Not sure this will ever work though.
Thanks for any help.
 
R

Rob Oldfield

Not sure if you're after moving data within controls or actually moving
controls... but I came up with this recently to allow a control to be
moved... just a form with a single rectangle control called recBox.

Option Compare Database
Public AllowMove As Boolean

Private Sub Form_Load()
AllowMove = False
End Sub

Private Sub recBox_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
AllowMove = True
End Sub

Private Sub recBox_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
If AllowMove Then
Me.recBox.Left = X + Me.recBox.Left
Me.recBox.Top = Y + Me.recBox.Top
End If
End Sub

Private Sub recBox_MouseUp(Button As Integer, Shift As Integer, X As Single,
Y As Single)
AllowMove = False
End Sub
 
J

Jesper F

That looks good too. My task is somewhere is mainly to visualize a move of a
control with 9x9 textboxes, but I think I can really put your example to
use. Thanks for your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top