Re-arranging form objects

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

Is it possible to give DB users the ability to re-arrange objects on a
continuous form to their liking?

If so, any suggestions?

Cheers,
Steve.
 
/What/ objects?

If it's a textbox: yes, you can write code that lets a user drag a
textbox around the form at runtime. You could remember the last
coordinates, and reposition it automagically the next time in.

If it's a single field from a datasheet: no, you can not drag those
fields individually.

HTH,
TC (MVP Access)
http://tc2.atspace.com
 
The Objects are text boxes.

Is it possible to provide an example of code? If a text box is dropped on
top of another, what happens to the text box being dropped on?

Thanks for your advice.

Cheers,
Steve.
 
If you put one box over another it will probably just obscure the
content of that other box. It depends on which control is "to the
front". You could easily experiment with this by putting two boxes onto
a form and dragging them manually around the form.

As for the code, in outline: you'd use the MouseDown event of the
textbox to set a flag when the user left-clicked over the box; then the
MouseMove event to follow the user's dragging action & move the box
accordingly (by changing the box'es Top and Left properties); then
MouseUp to detect when the user stopped dragging.

But why do you want to do this? How can it help the usr to be able to
drag the boxes around the form?

HTH,
TC (MVP Access)
http://tc2.atspace.com
 
I will have a go at the coding for that.

The DB/Form in question is used by a number of users to 'Quality Check' work
during one of the companies processes.

Each user will have their own style of performing these checks and prefer to
have the objects in different orders.

I can display the form in datasheet view which allows them to move the
columns around, but as they only have runtime access, they are unable to do
any sorting on the data, so the form has buttons to facilitate this (as well
as certain validations).

There is no way this company will provide the licences to the users so,
'user-friendlyness' is the key :)

Thanks,
Steve.
 
I can understand the desire to change the order of columns within a
datasheet view. But I just can't see the benefit of being able to drag
text-boxes around the screen. You say the users will prefer to have the
objects in different orders: but *why*? What will that achieve for
them, from a business perspective? I can't see it.

HTH,
TC (MVP Access)
http://tc2.atspace.com
 
I have started on the code to move one of the objects, but get the error
'2100 The control or subform control is too large for this location'.

Looking at the Help files, the X and Y values are in twips. I receive the
error when trying to apply the Y value to the Top of the object:

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single,
Y As Single)
If strTextBoxGrabbed <> "" Then
Me.Controls(strTextBoxGrabbed).left = X
Me.Controls(strTextBoxGrabbed).Top = Y
End If
End Sub

Any ideas?

Cheers,
Steve.
 
Sorry, its me!

Its a continuous form so the detail section is technically only as tall as
the text box!

Im getting there slowly....

Cheers.
 
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 ===
 
Note that each Private Sub statement must be on one line, through &
including the closing round bracket:

Private Sub ... ( ... ) ' < one line.

Google groups is showing a line break in the middle of each of those
statements.

TC (MVP Access)
http://tc2.atspace.com
 
That does the job! (I wasnt too far off :)

Heres one for you; The form is approximatley 2 screens wide, when dragging,
can the form be scrolled accordingly......

I am trying to come up with the code that could possibly move the text box
'behind' the dragged one, to the dragged one's old position.

Cheers,
Steve.
 
Back
Top