Move object

M

Maarkr

I always get the crazy requests... they want to add a record, show the record
as a field on the screen, then be able to move it around, so first things
first...
Trying to move a field using the arrow keys:
Private Sub Text87_KeyPress(KeyAscii As Integer)
'Debug.Print KeyAscii
If KeyAscii = vbKeyRight Then
Me.Text87.Left = Me.Text87.Left + 500
Repaint
ElseIf KeyAscii = vbKeyLeft Then
Me.Text87.Left = Me.Text87.Left - 500
Repaint
End If
End Sub
 
V

vanderghast

A record has a position in a recordset but not in a table. Unfortunately,
the recordset is not persisting (saving in a place surviving its own life
time) data. So, you have to save that 'position' in the table. Consider
adding a new field, 'positionInView', a decimal value (a float would become
too imprecise, and you will see why in a few seconds). Then, 'moving' a
record will be a matter to change its 'positionInView' value to become
0.5*(positionInView of the previous record in the recordset) +
0.5*(positionInView of the next record in the recordset). You may have to
play with a recordset clone to get other record positions in the recordset
since a recordset has one one 'position' at a time, it is called a bookmark,
technically though. Once the field will be modified, you may have to requery
the form, and move back to the first record you were having in view before
the requery.

Lot of work (and fine tuning details). I haven't even speak of how you 'drag
and drop' the actual record into its new 'viewable position'. Lot of work.
Nice to have work, but not nice to have too much, though (or more precisely,
not enough time to do the job intended to be done). Sorry, but the
'manager' (and you) are aware of the required development time for this
'functionality ? Sure, I may have missed a short cut, though, but if you
find one, please, teach me !



Vanderghast, Access MVP
 
M

Marshall Barton

Maarkr said:
I always get the crazy requests... they want to add a record, show the record
as a field on the screen, then be able to move it around, so first things
first...
Trying to move a field using the arrow keys:
Private Sub Text87_KeyPress(KeyAscii As Integer)
'Debug.Print KeyAscii
If KeyAscii = vbKeyRight Then
Me.Text87.Left = Me.Text87.Left + 500
Repaint
ElseIf KeyAscii = vbKeyLeft Then
Me.Text87.Left = Me.Text87.Left - 500
Repaint
End If
End Sub

And what is your question about that?
 
J

John W. Vinson

I always get the crazy requests... they want to add a record, show the record
as a field on the screen, then be able to move it around, so first things
first...
Trying to move a field using the arrow keys:
Private Sub Text87_KeyPress(KeyAscii As Integer)
'Debug.Print KeyAscii
If KeyAscii = vbKeyRight Then
Me.Text87.Left = Me.Text87.Left + 500
Repaint
ElseIf KeyAscii = vbKeyLeft Then
Me.Text87.Left = Me.Text87.Left - 500
Repaint
End If
End Sub

Is this a question? If so I don't understand it.

For one thing, you can move CONTROLS - textbox Text87 say - on a screen, but
you cannot move "fields". Is this an Access form? Is the data going to be
stored somewhere? Is the new *position* going to be remembered for the future?
If so on what basis?

More background please... what are your users trying to accomplish with this
rigamarole?
 
M

Maarkr

sorry if I wasn't clear, but I always have trouble conveying my requests. I
appreciate your patience in my odd requests; many times it may not be a
solution but gives me ideas to complete my projects.
The code below was my attempt to move a field(text87) on a form using the
arrow
keys, but it didn't move...
they asked for a database to show a map on a form, select a building on the
map and open a building diagram, and show locations of LAN and phone jacks on
the diagrams (over 1000). They want to add new jacks, and also be able to
move these jacks around on the form by using arrow keys/mouse.
I can get the data and forms (diagrams) to show a field with the jack ID for
each building, but I need help to 1) select the field and move it on the
screen using the arrows or mouse and 2) add a new field to the form using a
CmdBtn and assign a jack to it.
I lke the idea of assigning a postiion field in each record to position it
on opening. Maybe it's not possible to finish this-- like many others I've
started and is beyond the scope of my ability or Access is not feasible for
it, but I usually learn something and sometimes come up with some completed
projects that do some useful and unique things.
 
J

John W. Vinson

they asked for a database to show a map on a form, select a building on the
map and open a building diagram, and show locations of LAN and phone jacks on
the diagrams (over 1000).

That's a showstopper for doing it on an Access form right there: there is a
limit of 700 some controls on an Access form, over the lifetime of the form
(i.e. each time you add OR MOVE a control it counts toward the limit).

I suspect you'll need to use some other software for this application!
 
M

Maarkr

there's over a thousand jacks on the property, many buildings, floors, etc...
each form (floor diagram or portion thereof) (prob a subform or separate
form) may only have, say 50 max on each one or it would get too confusing to
show/move these fields on a form. I told them I could have them input a
grid coord as part of the record, but he said they want to move it to a
position on the diragram/form.
 
V

vanderghast

I suggest to use something like Visio (I haven't 'programmed' it in VBA,
though) to move 'shapes', or to use a general purpose development tool, such
as C# + Visual Studio + either winforms, or WPF.

Vanderghast, Access MVP
 
M

Marshall Barton

John said:
there is a
limit of 700 some controls on an Access form, over the lifetime of the form
(i.e. each time you add OR MOVE a control it counts toward the limit).


John, Shouldn't that be each time you add a control, it
counts toward the limit. Removing a control does not reduce
the count?
 
J

John W. Vinson

John, Shouldn't that be each time you add a control, it
counts toward the limit. Removing a control does not reduce
the count?

I believe you're correct, Marshall. I don't know if moving a control affects
this count (and I don't really want to add 768 controls to a form to find
out!)
 
M

Marshall Barton

John said:
I believe you're correct, Marshall. I don't know if moving a control affects
this count (and I don't really want to add 768 controls to a form to find
out!)


Neither do I ;-) OTOH, because setting the Left/Top
properties is not persistent, I can't imagine how it could
affect the design's total controls limit.
 

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