Create a new form with a single textbox called Text1. Copy the
following code into the form module. Then select it all, hit ctrl-x to
cut it, and ctrl-v to paste it back. (This ensures that the code is
connected to the textbox events.) Then save the module, save the form,
close the design view of the form, and run the form. Then click and
drag the textbox.
HTH,
TC (MVP Access)
http://tc2.atspace.com
'=== start code ===
Option Compare Database
Option Explicit
Private gDragging As Boolean
Private gX As Single, gY As Single
Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
If Button = acLeftButton Then
gX = X
gY = Y
gDragging = True
End If
End Sub
Private Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
If gDragging Then
With Me![Text1]
On Error Resume Next
.Left = .Left + (X - gX)
.Top = .Top + (Y - gY)
On Error GoTo 0
End With
End If
End Sub
Private Sub Text1_MouseUp(Button As Integer, Shift As Integer, X As
Single, Y As Single)
gDragging = False
End Sub
'=== end code ===