Results 1 to 5 of 5
  1. #1
    luckydead is offline Novice
    Windows 10 Office 365
    Join Date
    Nov 2020
    Posts
    25

    VBA InStr find text and import space

    Hello,
    Can someone help me about this:

    on my Table1
    Type - Short Text

    here i put for example text -> SG(C434)
    So what i want to do now.

    So my textbox (text44) is data control bounded to my table to read information.
    If I use textbox.text = someresult will not work I guest.

    In reports when i select my select and in textbox to display it like this -> SG (C434) , because i want the text after SG to goes down under the SG.

    For find text i readed and used this:
    If InStr(UCase(Text44.Text), "SG") Then
    'my work here


    End if

    Any ideas how can I make it,
    Thanks in advance.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    =mid(text44,Instr(text44,"(")+1)

  3. #3
    luckydead is offline Novice
    Windows 10 Office 365
    Join Date
    Nov 2020
    Posts
    25
    Quote Originally Posted by ranman256 View Post
    =mid(text44,Instr(text44,"(")+1)
    how can i use it like this?
    if i type: text44.Text =mid(text44,Instr(text44,"(")+1) I got debugger on this line stop work.

    or you mean in control source of textbox itself ?

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    To be honest I find it hard to follow your scenario...but I suspect part of your problem is here

    Text44.Text

    You can only refer to the Text Property when the Text44 Control has the Focus! Otherwise you need to use Text44.Value in referring to it.

    Since Value is the Default Property of Textboxes...you can simply use

    Text44

    as

    ranman256 did in his code

    =mid(text44,Instr(text44,"(")+1)

    Also, since Access (unless you explicitly diddle with it) is Case Insensitive, you don't need to use UCase.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    accesstos's Avatar
    accesstos is offline Expert
    Windows XP Access 2007
    Join Date
    Dec 2018
    Location
    Greece
    Posts
    551
    And, after the post of Missinglinq, the only thing a I have to add is this:
    Code:
    Me.Text44 = Replace(Me.Text44,"SG(","SG (")

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Grab text of string until space
    By sarcher in forum Access
    Replies: 4
    Last Post: 09-10-2019, 09:11 PM
  2. Replies: 2
    Last Post: 04-07-2016, 07:19 AM
  3. Replies: 16
    Last Post: 08-15-2014, 12:03 PM
  4. Eliminate Space from Hidden Text Box using CanShrink
    By Casey Sanders in forum Reports
    Replies: 4
    Last Post: 01-29-2013, 06:03 PM
  5. Space between two text boxes
    By ashbear in forum Reports
    Replies: 3
    Last Post: 08-17-2011, 05:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums