Textbox showing Memo column values being blanked out

D

Dean Slindee

My form has a text box that displays the contents of a memo column type.

When the textbox initially displays, the cursor is positioned at the end of
the text string.

Sometimes the text is highlighted, sometimes not.



If the first action that happens is pressing the Enter key (to create the
next line of text in the textbox), all the previous text disappears. (It can
be Undone and it will reappear). However, this is a very disconcerting
action to the users.

(By the way, this does not happen on a textbox displaying a varchar (255)
column).



On the other hand, if I first click on the cursor with the mouse, and then
hit Enter, the cursor moves to the

next line for entry of a new line of text (the desired action).



Can I somehow use KeyPreview and the KeyUp and KeyDown events to simulate
the second scenario when the first scenario happens?



Thanks in advance,

Dean S
 
J

John W. Vinson

Can I somehow use KeyPreview and the KeyUp and KeyDown events to simulate
the second scenario when the first scenario happens?

No, but you can use the SelStart and SelLen properties to do so: in the
textbox's GotFocus event, try something like

Private Sub txtMyMemo_GotFocus()
Me!txtMyMemo.SelStart = Len(Me!txtMyMemo)
Me!txtMyMemo.SelLen = 0
End Sub

Experiment with this a bit, this is from possibly rusty memory!

John W. Vinson [MVP]
 

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