Results 1 to 9 of 9
  1. #1
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544

    Question Replace "," with " "

    I need to run an update query to update any "," in a database to " ". The reason being is I am going to be exporting the data to a text file that is comma delimmited.

    Code:
    Dim i as integer
    Dim varPos As integer
    Dim varFindChar as string
    Dim varLookUp as String
    
    varLookUp = DLookup()
    FindChar = "s"
    
    For i = 1 To Len(varLookUp)
    If Mid(varLookUp, i, 1) = FindChar Then
    Pos = i
    End If
    Next i


  2. #2
    DaveT is offline Access Developer
    Windows 7 Access 2010 (version 14.0)
    Join Date
    May 2010
    Location
    Texas
    Posts
    69
    I would use update query using Replace such as
    Replace([myTextField], ",", " ")

  3. #3
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    also, if you open up the table, and hit ctrl+H, you open the "find and replace" dialog box =P. Remember, Access is still a part of MS Office

  4. #4
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    Quote Originally Posted by TheShabz View Post
    also, if you open up the table, and hit ctrl+H, you open the "find and replace" dialog box =P. Remember, Access is still a part of MS Office
    can you replace a "," within other words by this way?

  5. #5
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by jgelpi16 View Post
    I need to run an update query to update any "," in a database to " ".
    if this has to be done to all tables in a database, you'll want to loop the tables within a function and either write the EXECUTE command of the DATABASE object, or use the RUNSQL command without warnings.

  6. #6
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    Quote Originally Posted by weekend00 View Post
    can you replace a "," within other words by this way?
    Yea, just make sure you choose "any part" instead of "whole field". and if you put a space in the replace section itll replace with a space

  7. #7
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Folks,

    Always remember to backup or copy objects that you are modifying like this. Mistakes are very common when doing F & R's, and even UDF's like this. And they can't be undone in Access!

  8. #8
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Thanks for all the feedback. I had gotten so engrossed in the project I had completely forgotten about such a simple solution as F&R! However, this is going to be part of a process so I need something I can save (like a query or VBA code). I think I will use the update query approach. Thanks for all your help.

  9. #9
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    DaveT - Especially like your little picture! Thanks.

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

Similar Threads

  1. Replies: 6
    Last Post: 07-25-2012, 06:42 AM
  2. replace values with "indicators"
    By JoeMap in forum Reports
    Replies: 3
    Last Post: 06-16-2010, 10:19 AM
  3. replace a empty field with the word "none" how??
    By techexpressinc in forum Queries
    Replies: 1
    Last Post: 01-15-2010, 11:02 AM
  4. aSTR = Dir("C:\*.*") >> "Type Mismatch"
    By JGrant in forum Programming
    Replies: 1
    Last Post: 03-28-2009, 05:17 AM
  5. "Count" and "Countif" in Reports
    By JMantei in forum Reports
    Replies: 1
    Last Post: 06-20-2006, 02:20 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