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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

form, texboxes and code

Status
Not open for further replies.

and0b

MIS
Mar 27, 2007
51
US
Can someone please take a look at this piece of code? it is driving me crazy! All I want to have is three text boxes moving up as user is typing info in these textboxes, when cursor/active box stays in the middle of the form. For some reason it does not work as I want to. Here it is:

Private Sub Form_Load()

Me.lbl_fname.Top = 778
Me.lbl_fname.Visible = True
Me.txt1.Top = 1080
Me.txt1.Visible = True
Me.txt1.SetFocus

Me.lbl_lname.Top = 1498
Me.lbl_lname.Visible = True
Me.txt2.Top = 1800
Me.txt2.Visible = True

Me.lbl_address.Visible = False
Me.txt3.Visible = False
End Sub


Private Sub txt1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Me.lbl_fname.Top = 58
Me.lbl_fname.Visible = True
Me.txt1.Top = 360
Me.txt1.Visible = True

Me.lbl_lname.Top = 778
Me.lbl_lname.Visible = True
Me.txt2.Top = 1080
Me.txt2.Visible = True
Me.txt2.SetFocus

Me.lbl_address.Top = 1498
Me.lbl_address.Visible = True
Me.txt3.Top = 1800
Me.txt3.Visible = True
End If

End Sub

Private Sub txt2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Me.txt1.Visible = False

Me.lbl_lname.Top = 58
Me.lbl_lname.Visible = True
Me.txt2.Top = 360
Me.txt2.Visible = True

Me.lbl_address.Top = 778
Me.lbl_address.Visible = True
Me.txt3.Top = 1080
Me.txt3.Visible = True
Me.txt3.SetFocus
End If

End Sub

Private Sub txt3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Me.txt1.Visible = False

Me.txt2.Visible = False

Me.lbl_address.Top = 58
Me.lbl_address.Visible = True
Me.txt3.Top = 360
Me.txt3.Visible = True
End If

End Sub
 
Yes, it works different(?!) but still not right! I have problem not with triggering event but with boxes which should move in the place of each other but they wont.

Andrew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top