Moving an object

astarbyfar

Registered User.
Local time
Today, 15:54
Joined
Apr 27, 2003
Messages
93
Im wondering if anyone has any ideas. I have a field which declares an integer call it Presses. If Presses is equal to five I want to be able to move a text box to a different location i.e. More up the page. At the moment i am looking at the code;

If Me.Presses = "5" Then
Me.Text5.Top = "5.804"

However this doesnt work. The left coordinate stays as it should but the Text box goes to Top = 0. Any suggestions?
 
I tried it, and the text box does move. Try a larger number than "5" to show that it moves (like 250).
 
No, Im still not able to move it! Im using exactly the same code as before and its simply sending the text box to top 0. Im using XP in case the version matters!
 
You're using exactly the same code and expecting a different result? :eek:
Try mondo's suggestion... Me.Text5.Top = 250
Access measurements are in a unit called "Twips" of which there are 1440 in an inch. Moving something to 5 moves it about 0.004 inches, invisible to the naked eye.
Move something half an inch down using something like...
Code:
Me.Text5.Top = Me.Text5.Top + 0.5 * 1440
:)
 
No Im afraid the above suggestions are still not working. Im still using;

Private Sub Presses_AfterUpdate()
If Me.Presses = "5" Then
Me.Text5.Top = "2500"
End Sub

Is the syntac correct?
 
what's with the quotes!!!!!
Me.Text5.Top = "2500"
get rid of the quotation marks - it's a number.

izy
 
The quotes dont make any difference. It still doesnt work regardless of whether there is quotes or not. Its just programming preferences!!
 
you are right.

i just tried
myBox.Top = "1500"
and it worked

oh well, it's good to learn something new every day.

izy
 
Sorry about this but has anyone got anymore suggestions. I dont see why the .Top function isnt working!
 
I take it by the lack of responses that Im trying to do the impossible! I need to create a form which saves data about a " Press Line." In each Press Line there are a number of Pressses sometimes 5 but mostly six which have there own information. However for those lines which only have 5 Presses I want only 5 data entry points to be visible. Is there a simplified version of this that I can attempt? If i make the data entries height and width to 0, there will still be a huge gap on my form. Thanks in advance
 
This does work and you are not trying to do the impossible. Check that its not the code that determines what 'Presses' equals thats not truiggering the event. Stick something like.

Me.myControlNameHere.Top = Me.myControlNameHere.Top - 5

on the on click event of a button and keep pressing it. You'll see the control move up from its original position to a new possiton that is 5 twips higher than the original position.

I also assume that you know that the value you are giving it for the new position is different from the original position. If not it won't be seen to move.
 
Dan thanks very much mate I eventually got there! You was correct it was in the wrong event! Cheers Mike
 
Oh well!

Ive now found a new problem. Each time a user updates a form the code is executed again i.e. everything is moved up again!. Is there anyway of preventing this. Im using the AfterUpdate() event is this correct?
 
Mike there are many ways to determine this. If you have used me.control.top=me.control.top - 5 then yes each time the function is called it will move it up by 5.

You could either define a variable and store the height you want the control to move to so if its called the control will be moved to that height even if its already at that height.

or when its called determine the position and if its not at the height you want run the code. Use and if statement such as. If me.control.top <> (n) then me.control.top= (N)

and finally just recheck your design ideas and ask why you want the control to move in the first place. Are you sure this is the best option for what you are trying to achieve.

Dan
 
You could use globals. Or, you could create your own table to store the information. Tables that store data about data are referred to as metadata tables.

This way you can save the properties even when you close the database.
 
Its fine Ive now just used Dans advice and used constants to declare the new locations of objects when a certain event happens. Howevere is there a way of restoring the original values of the form i.e. the ones which are created in the design procedure? Cheers Mike
 
Either as modest says declare a constant for the original value, or on open set a public valiable to equal the original value or use and if statement to determine which value to use for the height.
 

Users who are viewing this thread

Back
Top Bottom