Results 1 to 5 of 5
  1. #1
    jhjarvie is offline Novice
    Windows Vista Access 2003
    Join Date
    Sep 2008
    Posts
    12

    How to make a field accept No spaces

    I have a field called 'txt_Part_Number' and I would like this field to accept any letters or numbers but NO spaces!!



    Any ideas how to do this?

  2. #2
    dcrake's Avatar
    dcrake is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    435
    You could tackle this in 2 ways

    1. use the keypress/keydown event on the control to test for a space, and if encountered issue a backspace.

    2. on the before/after update event use Replace(Me.ActiveControl," ","") to trim out any spaces.

    David

  3. #3
    jhjarvie is offline Novice
    Windows Vista Access 2003
    Join Date
    Sep 2008
    Posts
    12
    Quote Originally Posted by dcrake View Post
    You could tackle this in 2 ways

    1. use the keypress/keydown event on the control to test for a space, and if encountered issue a backspace.

    2. on the before/after update event use Replace(Me.ActiveControl," ","") to trim out any spaces.

    David
    Looks good, but I am getting a compiler error......."Expected = "
    Any ideas??

  4. #4
    jhjarvie is offline Novice
    Windows Vista Access 2003
    Join Date
    Sep 2008
    Posts
    12
    Quote Originally Posted by jhjarvie View Post
    Looks good, but I am getting a compiler error......."Expected = "
    Any ideas??

    Silly me!! I have it now, albeit a slightly different coding.......

    Me.Part_No = Replace(Me.Part_No, " ", "")

    Thanks for the help

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Are you satisfied enough to use the Solved thread tool?

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

Similar Threads

  1. Find Spaces in Field
    By stottle in forum Queries
    Replies: 6
    Last Post: 08-17-2009, 02:02 AM
  2. Replies: 3
    Last Post: 04-12-2009, 05:11 PM
  3. Form does not accept data
    By bongo in forum Forms
    Replies: 3
    Last Post: 03-14-2009, 01:52 AM
  4. Replies: 2
    Last Post: 09-01-2006, 04:03 PM
  5. Replies: 1
    Last Post: 12-09-2005, 09:27 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