Results 1 to 8 of 8
  1. #1
    jre1229 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jan 2012
    Posts
    30

    Adding * to beginning and end of textbox text

    After a user tabs off of the field they were just in, I would like to add an * at the beginning and end of that text. I need the * in the front and back so that our barcode scanner will read the barcode correctly but I don't want to have to rely on someone to manually enter the * every time. Any ideas?

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    What is the data type of the data in the field to which you want to add the two *s?
    I mean - what kind of data is going to be in that field?

  3. #3
    jre1229 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jan 2012
    Posts
    30
    It's numbers but I have it set to Text so that it will accept *'s

  4. #4
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    You can put something like this in the 'On Lost Focus' Event of the text box.
    Code:
     
    Me.YourTextBoxName.Text = "*" & Me.YourTextBoxName.Text & "*"
    Let me know if this works for you.

  5. #5
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Quote Originally Posted by Robeen View Post
    You can put something like this in the 'On Lost Focus' Event of the text box.
    Code:
     
    Me.YourTextBoxName.Text = "*" & Me.YourTextBoxName.Text & "*"
    Let me know if this works for you.
    and if that doesn't work (which will probably not work because you used .TEXT which needs to have focus and so you will get an error as the lost focus means it isn't selected anymore), you most assuredly can use this:

    Me.YourTextBoxName = Chr(42) & Me.YourTextBoxName & Chr(42)

  6. #6
    jre1229 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jan 2012
    Posts
    30
    Great idea! I didn't use this but you did spark an idea. I actually left the data going into the database without the * then when I pull it out for a report I add the *.

  7. #7
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Quote Originally Posted by boblarson View Post
    and if that doesn't work (which will probably not work because you used .TEXT which needs to have focus and so you will get an error as the lost focus means it isn't selected anymore), you most assuredly can use this:

    Me.YourTextBoxName = Chr(42) & Me.YourTextBoxName & Chr(42)
    Bob - I tested the code before I posted. It works.

  8. #8
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Quote Originally Posted by Robeen View Post
    Bob - I tested the code before I posted. It works.
    Regardless, you should not use .TEXT if at all possible. Use .Value instead unless you can't.

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

Similar Threads

  1. Adding Textbox value into Table
    By sikhinvestor in forum Access
    Replies: 2
    Last Post: 06-05-2014, 07:29 AM
  2. Adding Hyperlink into Textbox with Text
    By tylerg11 in forum Forms
    Replies: 5
    Last Post: 11-07-2011, 01:58 PM
  3. Remove/Ignore beginning of text file on import
    By Insyderznf in forum Import/Export Data
    Replies: 9
    Last Post: 10-24-2011, 04:56 PM
  4. Replies: 3
    Last Post: 09-20-2011, 11:54 AM
  5. Replies: 2
    Last Post: 11-16-2010, 10:55 AM

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