Ommited spaces

G

Guest

I am trying to set the selstart of a textbox(1) to the len() value of the
same textbox(1) (NB i have a function in the middle that highlight another
textbox(2) then comes back to textbox(1) during a OnKeyPress function).

the problem lies when coming back to the textbox(1) it does not record
spaces made by the spacebar!

how can i solve this, any ideas?
 
G

Guest

Any keystrokes you make affect only the control that has the focus. If you
are moving to a different control and coming back, textbox(1) knows nothing
about those other keystrokes.

What is it you are trying to do?
 
G

Guest

I am trying to calculate the number of characters in the text box and update
the calculation on a keypress (the calculation "=len(textbox) is in another
text box) and the only way it updates on each key press is if it is given
focus.

so i give the counter focus then return to the original textbox. this works
fine until the last character is a <space> this is not calculated.

any help?
 
G

Guest

Actually, this is the perfect place to use the Change event. The Change
event fires on every keystroke, so you do not need to change the focus, you
just need to put the code in the text box's Change event. Assuming you are
entering the data in a text box named txtSomeStuff and you want the length of
the text in txtSomeStuff to display in a textboxed named txtShowYourStuff:

Private Sub txtSomeStuff_Change()
Me.txtShowYourStuff = Len(Me.txtSomeStuff)
End Sub

You will also want to put the same code in the form's Current event so it
will show the correct value when you move to a differnt record.
 

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