Hi there,
Is there a macro or other shortcut to replace the first 5 numbers in a whole column of numbers with 99999? I've been doing this manually and it's a royal pain.
Thanks!
--Todd
Hi there,
Is there a macro or other shortcut to replace the first 5 numbers in a whole column of numbers with 99999? I've been doing this manually and it's a royal pain.
Thanks!
--Todd
Run an "Update" query. Something like:Code:UPDATE YourTableName SET YourTableName.YourFieldName= "99999" & Mid("YourFieldName",5);
If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
Bob Fitzpatrick
The expression needs one change :
UPDATE YourTableName SET YourTableName.YourFieldName= "99999" & Mid("YourFieldName",6);
Everything after column 5 starts in column 6.
John
You are of course quite right about the "6", but I've just realized that the quote marks around the YourFieldName should actually be square brackets. So I think it should be:
UPDATE YourTableName SET YourTableName.YourFieldName= "99999" & Mid([YourFieldName],6);
If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
Bob Fitzpatrick
OK, so how do I do this for an entire column of data?
If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
Bob Fitzpatrick
No, just the first 5 digits.
I apologize but I am a total Access newbie. I am trying to use the query design. I don't see anywhere to add a whole line of code like you are instructing.
I have the query run to select the data, and now it is asking for "Update To:".
Don't worry, I am trying this on a copy so I don't mess up the original..
OK, I figured out I have to place "99999" & Mid([YourFieldName],6) in the Update To: box. It appears to work. Can I get it to ignore cells with nothing in them?
Said, we should have warned you about making a backup.No, just the first 5 digits.
I apologize but I am a total Access newbie. I am trying to use the query design. I don't see anywhere to add a whole line of code like you are instructing.
I have the query run to select the data, and now it is asking for "Update To:".
Don't worry, I am trying this on a copy so I don't mess up the original..
Anyway, copy the posted code. open a new query in Design View. If you get a Dialog box open asking you which tables to add to the query, just close it, without selecting any tables. Once it has closed you should see a button on the toolbar with SQL on it. Click that then paste the code into the open pane. Then click the Run button on the toolbar. It looks like an exclamation mark.
If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
Bob Fitzpatrick
Hi, sorry, re-posting so you see this:Said, we should have warned you about making a backup.
Anyway, copy the posted code. open a new query in Design View. If you get a Dialog box open asking you which tables to add to the query, just close it, without selecting any tables. Once it has closed you should see a button on the toolbar with SQL on it. Click that then paste the code into the open pane. Then click the Run button on the toolbar. It looks like an exclamation mark.
OK, I figured out I have to place "99999" & Mid([YourFieldName],6) in the Update To: box. It appears to work. Can I get it to ignore cells with nothing in them?
Filter the records to be updated:
WHERE [YourFieldName] Not Is Null
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
Bob Fitzpatrick
OK, the "Is Not Null" goes into the "Criteria" parameter. Done!
Thanks!!
ttng73
Did you see June's post. That would go on the end of the code I posted, or you could change the query to Design View and put
Not Is Null
in the "Criteria" row.
If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
Bob Fitzpatrick
I did see it, thanks all!