Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing a text boxes position after update of another text box 1

Status
Not open for further replies.

GoinDeep

Technical User
Jan 9, 2003
100
US
I have never tried changing the position of a text box on a form which is probably why I am doing it wrong...I simply tried the following:

On Current:
If Me.textbox = "T" Then
Me.textbox1.Visible = False
Me.textbox2.left = 1.333
Me.textbox2.top = 1.8333
Else
Then back to normal...
End If

Please tell me where I have went wrong? This just sends the text box to the top of the form. Thanks for any help...
 
your code within the if should be correct. But it's the on current event what is the problem. On current event happens whenever a record is loaded. You need an event that happens whenever a textbox value is changed.
try the on change event of the textbox you enter T in your example.

You could also try the lost focus event. This occures when the cursor moves out of the textbox.

Both should work, but to be 100% correct, you should use the on change event.
 
Distance on an Access form are in Twips (1440 per inch). So in your case you have to multipy the value you want by the 1440 to get positioning:

Code:
On Current:
   If Me.textbox = "T" Then
      Me.textbox1.Visible = False
      Me.textbox2.left = 1.333*1440
      Me.textbox2.top = 1.8333*1440
   Else
      Then back to normal...
   End If

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB/Access Programmer
 
Well, I actually errored in my subject. What I really need is when this particular text box equals "T", then I don't need this other text box to display and I want to move another in it's place. So I used OnCurrent for that, and on the text boxes after update event I used Form_Current.

I am starting to think the measurments used for top and left are different from the text box properties than they are when using them in VB.
 
I figured it was something like that...however, I tried that and it is still sending the text boxes way off.

The measurment I have is from the Properties menu
 
Hmmm...Not exactly sure what is going on in your case, but I ran a test using the following:

Code:
Private Sub Command4_Click()

    Me.ServiceNumber.Top = 1.3333 * 1440
    Me.ServiceNumber.Left = 2.5 * 1440

End Sub

And my Service Number field jumped to where I expected it to based on the 1.3333 inches and 2.5 inches. Do you maybe have your ruler set to centimeters??? That would require further conversion as twips are 1440 per inch (I don't know what that is in centimeters)

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB/Access Programmer
 
Found it....567 twips per centimeter FYI.

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB/Access Programmer
 
Great...I found the problem...I forgot to change the "Else" portion. That was very helpful...thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top