Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    ldodge is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2011
    Location
    Wisconsin
    Posts
    43

    Lawrence


    Hi all-
    I have a field (text) that currently has between a 4 and 6 digit number in it. I need to add the letter "R" to all entries in the field. Any thoughts on how to do this. (Once it is done, I have a validation rule to ensure new entries get the "R")

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Create an Update Query.

    Post back if you need more help.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    ldodge is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2011
    Location
    Wisconsin
    Posts
    43

    update query

    Before I really screw it up and loose all the existing #'s, please give me a detailed code to do this. Thanks
    LCD

  4. #4
    nicknameoscar is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Apr 2011
    Location
    Earlysville, VA
    Posts
    91
    Before you screw up and loose[sic] all the existing #'s - make a backup copy of your database and experiment with one or the other.

  5. #5
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Can you tell us the name of the field to be changed and the name of the table that holds the field.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  6. #6
    ldodge is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2011
    Location
    Wisconsin
    Posts
    43
    SpecSheets is the table
    Product# is the field

  7. #7
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Hi

    First and most important. MAKE A BACK UP !


    If the field is actually called Product# with the # sign
    use this
    Code:
    UPDATE SpecSheets SET SpecSheets.[Product#] = "R" & [Product#];
    If the field is actually called Product# without the # sign
    use this
    Code:
    UPDATE SpecSheets SET SpecSheets.Product = "R" & [Product];
    Cut and paste the require code into the SQL of a new query.
    Then click the "Run" icon on the main toolbar (It looks like an exclamation mark ! ) .
    Only do this once. Each time the query is run the "R" will be added to all existing records.

    Job done.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  8. #8
    ldodge is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2011
    Location
    Wisconsin
    Posts
    43
    What did I do wrong, I went to the update query screen and entered in the code you gave me in the "Update To:" line (see attached), then "run query" and nothing happened.

  9. #9
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    When you say you "ran" the query, what exactly did you do?

    If you clicked the icon on the far left of the toolbar then this is incorrect.
    You need to click on the "Run" icon on the main toolbar (It looks like an exclamation mark ! )
    You will know you have the correct icon if you hold the mouse pointer over it because the word "Run" will popup.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  10. #10
    ldodge is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2011
    Location
    Wisconsin
    Posts
    43
    In the Disign tab in results group, i clicked on the red !

  11. #11
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Sorry, I've only just noticed that you are using A2010. I got a bit mixed up because I've also been helping someone using A2003.

    I haven't used A2010 so the toolbar placings etc may well be different.

    Have you managed to run the update query now? or do you need some help from someone more familiar with A2010?

    If you've managed to run it, did it work?
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  12. #12
    ldodge is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2011
    Location
    Wisconsin
    Posts
    43
    No it still doesn't work. Oh well thanks for your help
    LCD

  13. #13
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    You could also paste this proc into a General module

    Code:
     
    Public Sub UpdateMyTable()
    On Error GoTo Err_UpdateMyTable_Error
        DoCmd.RunSQL "UPDATE SpecSheets SET SpecSheets.[Product#] ='R' & [Product#];"
    Exit_ErrorHandler:
        Exit Sub
    Err_UpdateMyTable_Error:
        MsgBox "Error " & Err.Number & " (" & Err.Description & ") "
        Resume Exit_ErrorHandler
    End Sub
    and run it to do the same job.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  14. #14
    nicknameoscar is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Apr 2011
    Location
    Earlysville, VA
    Posts
    91
    I don't have Access 2010 either but can you post the SQL statement for the query that you posted an image of a few posts up? The image is not totally clear (even after I click on it) but it looks like there is a - (dash) to the left of the "R-" (or is that an = ). I don't think I have used an = in front of an Update expression before.

    What error messages do you get or does it say it is updating X number of records but no records are updating.

    Also, from what I have read it is not a good idea to use symbols (such as #) in table field names.

  15. #15
    nicknameoscar is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Apr 2011
    Location
    Earlysville, VA
    Posts
    91
    Just saw a post by one of the experts here (sorry, forgot the name of that expert already - old age is for the birds) that said you have to supply a criteria for an Update query (I did know that but totally forgot). So, put a Like * or Not Is Null statement in the criteria field.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

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