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

Order of Events 1

Status
Not open for further replies.

Thorny

Programmer
Jul 2, 2001
23
GB
I have a text box in which users are to enter numbers, I would like a function I have created to be triggered after each number has been entered not only after the text box has lost focus or by using the After_Update event. Please help, have wasted alot of time to no avail with this
 
Need a little more detail. How about showing the code behind the textbox so we know what's going on.

Ian Mayor (UK)
Program Error
Always make your words sweet and nice. Because you never know when you may have to eat them.
 
This will do it:

Code:
Private Sub YourTextBoxName_Change()
  'Place you code to run function here
End Sub

Linq


The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
I tried putting my code in the On_Change event, doesn't work, have also tried the On Key Up, Down and Press events. Add the following code in the:

Private Sub Textbox_Change()
MsgBox Texbox
End Sub

If I key in the number 1 into the text box, surely the number 1 should be displayed in the Message Box, this is not so, it still contains a Null?

 
Your code

Private Sub Textbox_Change()
MsgBox Texbox
End Sub

won't display anything, under these circumstances (while the textbox still has focus) unless your textbox is a bound to a field and has had data in it previously!

The Default Property for Texbox is .Value, so you're really saying

Private Sub Textbox_Change()
MsgBox Texbox.Value
End Sub

The problem with this is that a textbox has no Value until you've exited the textbox!

In this situation you need to use the .Text property:

Private Sub Textbox_Change()
MsgBox Texbox.Text
End Sub


Note that .Text can only be used while the textbox in question has focus! It'll bomb if you use it otherswise! When the textbox doesn't have focus then you use either Texbox or Texbox.Value

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top