Results 1 to 8 of 8
  1. #1
    veiko is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jan 2015
    Posts
    3

    How to trim from "text box" data after enter.

    I have lately strugling seemingly with simple thing how to trim from "text box" data after enter. Shortly, user enter data with barcode scanner(we can't trim barcode scanner) and after enter data textbox must cut automatically some data from end (or beginning) 6 characters. After that access automatically finding from database right data and shows it(but data what i want to search is not same between database and entered data to textbox and because i must trim after entering data from textbox). Can anybody help me we seemingly simple thing, i've looking from google but can't find anything about it.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Use string functions to manipulate string data: Left, Right, Mid, InStr, InStrRev, Len.

    I don't really understand all you describe. What exactly do you need to trim? Show example data.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    veiko is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jan 2015
    Posts
    3

    Again :)

    Quote Originally Posted by June7 View Post
    Use string functions to manipulate string data: Left, Right, Mid, InStr, InStrRev, Len.

    I don't really understand all you describe. What exactly do you need to trim? Show example data.


    Sorry, english is not my homelanguage and i try to explain again .
    On the Form is textbox, behind this textbox is vba code what search from database and which shows automatically result under this textbox.
    User entering data with barcode scanner (we can't configure barcode scanner to trim data) example1 "abcdefghi.12345687890" but in database is different data example2 "abcdefghi.1234zxcvbn"(different last 6 characters). You can notice that is difference between 2 example data, from second example is different 6 character when first exmaple, by the way this data is same and i can't search from entered data (example1) before when i at first delete last characters, because it is different from database(example2). Now i must somehow cut or trim last 6 character automatically from textbox after it entered with barcode scanner before it can search and show result from database.
    I understand how to trim in database, but in database must stay same value and i can't change it. Only option is it change "textbox" value(delete last 6 characters) before it will searching data, but i don't know how to do it!

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Use the functions I listed. Search Access Help or web to learn more about string manipulation.

    Left(Me.textboxname, Len(Me.textboxname)-6)
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    You could review the SelStart and SelLength properties of textbox and see if these are relevant.

    Often, instead of trying to explain in language, a simple example will show the input and desired output.
    A picture may be worth 1000 words.

  6. #6
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by veiko View Post

    ...Only option is it change "textbox" value(delete last 6 characters) before it will searching data...
    Much of your explanation is still not clear, but if the above statement is the core of what you're trying to accomplish, June7's example

    Left(Me.textboxname, Len(Me.textboxname)-6)

    will do the job once you replace textboxname with the actual name of your Textbox.

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

    All posts/responses based on Access 2003/2007

  7. #7
    veiko is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jan 2015
    Posts
    3
    Click image for larger version. 

Name:	access.jpg 
Views:	14 
Size:	142.9 KB 
ID:	19453
    now i made at first new button to test this and put in this button code "Left(Me.txtSearch, Len(Me.txtSearch)-6)" - textbox name is "textSearch" but it gives compile error, you can see this error on attached picture. What went wrong?

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Have to use the expression to set the value of something - in textbox ControlSource, in VBA to set variable, or use it in a query to create a calculated field. Examples:

    =Left(fieldname, Len(fieldname)-6)

    Me.textboxname = Left(Me.textboxname, Len(Me.textboxname)-6)

    Dim strUPC As String
    strUPC = Left(Me.textboxname, Len(Me.textboxname)-6)

    SELECT *, Left(fieldname, Len(fieldname)-6) AS ShortUPC FROM tablename;
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 8
    Last Post: 07-15-2014, 05:56 PM
  2. Unbound text box data type and "Delete" function
    By gaker10 in forum Programming
    Replies: 16
    Last Post: 06-13-2014, 10:46 AM
  3. Replies: 7
    Last Post: 07-19-2013, 11:58 AM
  4. Replies: 3
    Last Post: 06-06-2013, 08:22 AM
  5. Export "Query or Report" to a "Delimited Text File"
    By hawzmolly in forum Import/Export Data
    Replies: 3
    Last Post: 08-31-2012, 08:00 AM

Tags for this Thread

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