Results 1 to 4 of 4

Thread: Dilemma with Using a Form and textbox with Access

  1. #1

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,602

    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.
    Wen Gang, Programmer
    VB6, QB, HTML, ASP, VBScript, Visual C++, Java

  2. #2

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,602

    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.
    Wen Gang, Programmer
    VB6, QB, HTML, ASP, VBScript, Visual C++, Java

  3. #3
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    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

  4. #4
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Dilemma with Using a Form and textbox with Access

    IMO, .SelStart = 0 is the best way to go
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width