Results 1 to 7 of 7
  1. #1
    andrei186 is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2011
    Posts
    3

    add a specified character to every record in a colume?

    How shal I add a specified character to every record in a colume?


    I tried

    UPDATE table_name
    SET field_name ='character' +field_name

    But on the first run it returned the correct colume but with no character added

    When closed and attemted to run again? it would not open saying "this action has been blocked in the switch-off mode" (I tranlate it from Russian into English so the actual wording in English might be different)

  2. #2
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    I dont think you can update a field with itself. Try creating a brand new field and updating that one. So:
    UPDATE TableName
    SET NewField = "character" & OldField

    Then delete the old field and rename the new one to what the old one was.

    The & and + shouldn't matter in your case because it is a string, but I'd recommend getting away from + and using & as if you try to concatenate to numbers with + you're going to add them together instead.

  3. #3
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538
    Try this:

    UPDATE table_name
    SET table_name.field_name ="character" & [field_name];

    This worked for me in a sample db.

    Alan

  4. #4
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    GUess you can update a field with itself. Thanks, Alan.

  5. #5
    andrei186 is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2011
    Posts
    3
    Thank you, both.
    On both versions of the query I have the same result as with my first code - the query would not run but throws a warning "this action has been blocked in the switch-off mode" - what might this mean? It looks like the problem is not the query syntax but some setting of my database? This is Access 2007 on XP

  6. #6
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538
    Andrei;

    Difficult to say without seeing the db. Suggest you post a copy with limited data included. Run a compact and repair before uploading and also suggest you remove any confidential data. Post as an earlier version as many users on this forum are still running 2003/2002 versions of Access and you want maximum viewers to look at this.

    One last thought: is the field you are trying to update a text field and are you trying to add text to it? I wonder if there is a data mismatch that is causing this.

    Alan

  7. #7
    andrei186 is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2011
    Posts
    3
    Thanks, Alan.
    I've just created a small test DB from the scratch and your query worked in it.
    So the problem is indeed in DB. It is quite a big one (four tables of about 1000 records each). Before bothering you with it I'll try to play with it myself, and if fail, will use your invitation.
    One thing which might be relevant:
    this DB has actually been created time ago when this computer was running w2k and the DB was created with ACCESS-2000. Now I run it on XP/Access2007 ( (BTW I think I should drop XP and Office-2007 because of so many small annoying things, and go back to w2k-Office2000)) - perhaps this might have to do with that warning message?
    PS I forgot to tell that the field is a text one, and its length is suffficent to accomodate another character

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

Similar Threads

  1. replace a character with a wildcard
    By neeedhelp in forum Programming
    Replies: 2
    Last Post: 04-11-2011, 05:02 PM
  2. SQL wildcard character excluding
    By sandlucky in forum Access
    Replies: 2
    Last Post: 03-28-2011, 03:33 AM
  3. Character Limits
    By nashr1928 in forum Reports
    Replies: 5
    Last Post: 12-08-2010, 01:29 PM
  4. filter by the number of character
    By bangemd in forum Access
    Replies: 1
    Last Post: 06-30-2009, 10:33 AM
  5. Replies: 0
    Last Post: 10-28-2007, 09:11 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