Newbie questions about forms...

B

Bill

I am new to using forms in Access, and I am having trouble with what I
think should be a simple task. I am trying to update the value of a
text box, based on keyboard entry in another text box. I am trying to
use data from different sources to build a string of characters, but I
would like the result to be updated as the user types. I have tried
using keypress, keydown, keyup, etc, however, I can't seem to update
the values as the user types, and I am only seeing the first
keystroke. I tried using refresh at each keypress, but that moves the
cursor back to the beginning of the string in the text box. For
example, if a user types "ABC" in one text box, I would like to see
each character echoed in another text box as he types. I have been
searching the web, and the news groups, but I haven't yet found an
answer. I hope this question makes sense, unfortunately, I don't have
enough experience with forms to even ask an intelligent question.

Thanks.
 
K

Kel

Try something like this using the KeyPress event (TxtBox1 is the box you
type in, TxtBox2 the box which will echo it)

Private Sub TxtBox1_KeyPress(KeyAscii As Integer)
TxtBox2 = TxtBox1.Text & Chr(KeyAscii)
End Sub

Hope this helps
Kel
 
N

none

Thanks, I found my problem, but I will try your example also. I didn't
understand the difference between TxtBox1.Value and TxtBox.Text, and how
Value does not get updated until the TextBox loses focus (I think?).

Thanks,
Bill

On Fri, 02
 
K

Kel

Glad you sorted it!

The Value property is the last saved data for that control - this is updated
when the textbox loses focus (as you said!), whereas the Text property takes
the text that is currently in the textbox (which hasn't necessarily been
saved) and so may be different to the Value.

Kel
 

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