Dilemma with Using a Form and textbox with Access
I think this is the right forum since the question is db related really.
I had to build this app in Access, because that is the only thing I'm allowed to code in at the office.
I created a form and put some labels and textboxes on it. One box is txtNotes, where I put notes on particular records (yes they are coming from the db, but the question is more about the object). Initially, I wanted to have a vertical scrollbar on this large text box, so that when the note was too large, the user could scroll down. I found that on the Access Form, the textbox has to have focus to show the scrollbar. That was fine. I set focus to it as the last step each time.
Then I encountered a new issue. I was using txtNotes.Text = RS("notes") and eventually, one of my notes was too long and I got an error telling me so. To fix this, I switched from txtNotes.Text to txtNotes.Value. That solved the "too long" problem, but created a new problem. Now when .SetFocus kicks in, the entire contents of the box is highlighted.
So the problem is, if I don't Set Focus, then I don't get scrollbars. If I do set focus, then my text gets highlighted. I could set .Value back to .text, but then some of my notes will be too long. (BTW, what is the limit, I haven't found it anywhere).
So that's it. Suggestions?
I should mention that the text in the box is a mix of English and Chinese, so any ideas that involve counting characters and acting accordingly will be hard to implement with any accuracy.
Thanks.
Re: Dilemma with Using a Form and textbox with Access
OK. I think this is solved.
I added the line:
txtNotes.SelStart = 0
That moves the cursor to the beginning of the text.
It isn't a perfect solution, but it works. These textboxes have to have focus to show scrollbars, so there is no really good alternative to having Focus Set on the box.
Re: Dilemma with Using a Form and textbox with Access
Weng
If you're still having a "too long" issue, perhaps you could
first check the length of the string. My guess (purely a guess)
is that the max is around 65,000 characters.
So, assuming that's the max, perhaps you could truncate at the max.
Perhaps you could "save the rest" to another variable, and post it in
another textbox if desired.
Spoo
Re: Dilemma with Using a Form and textbox with Access
IMO, .SelStart = 0 is the best way to go :)