In a table I have a textfield containg data like B09-001, B09-002 etc.
Now I am almost at B09-999, so I like to insert a "0" so that the data look
like B09-0001, B09-0002, B09-0999 etc.
How can I do that with a update-query?
|
|
0
|
|
|
|
Reply
|
Utf
|
11/16/2009 1:34:01 PM |
|
If you have a single field into which you have stuffed two (or more) facts
(i.e., "B09" and apparently a sequence number), you have (re-)discovered why
it is not good database design to stuff two (or more) facts into a single
field!
Before you proceed any further, consider creating two new fields in your
database, one for each fact. Then you can use a query to concatenate the
first fact ("B09") with a hyphen ("-") and the sequence number, formatted
any way you want.
And if the "B09-" is constant, you don't even need the first field, just a
sequence number field!
Good luck!
--
Regards
Jeff Boyce
Microsoft Access MVP
Disclaimer: This author may have received products and services mentioned in
this post. Mention and/or description of a product or service herein does
not constitute endorsement thereof.
Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.
You can thank the FTC of the USA for making this disclaimer
possible/necessary.
"BlackKnight" <BlackKnight@discussions.microsoft.com> wrote in message
news:86C78273-0BAC-4B5B-9127-E7F0B4B11DD6@microsoft.com...
> In a table I have a textfield containg data like B09-001, B09-002 etc.
> Now I am almost at B09-999, so I like to insert a "0" so that the data
> look
> like B09-0001, B09-0002, B09-0999 etc.
> How can I do that with a update-query?
|
|
0
|
|
|
|
Reply
|
Jeff
|
11/16/2009 1:46:29 PM
|
|
You might use an update query. For your very specific example that could look
like the following.
UPDATE YourTable
SET YourField = Replace([YourField],"-","-0")
WHERE YourField LIKE "B09-###"
==Create a new query
==Add your table
==Add your field
==Set the criteria under field to be changed to
LIKE "B09-###"
==SELECT Query: Update from the menu
==In the Update to "box" under the field enter
Replace([YourField],"-","-0")
The above assumes you are using Access 2000 or later. And if you are using
Access 2000 that it is patched to SP-3 level.
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
BlackKnight wrote:
> In a table I have a textfield containg data like B09-001, B09-002 etc.
> Now I am almost at B09-999, so I like to insert a "0" so that the data look
> like B09-0001, B09-0002, B09-0999 etc.
> How can I do that with a update-query?
|
|
0
|
|
|
|
Reply
|
John
|
11/16/2009 2:28:09 PM
|
|
I am using Access97.
I already came as far as using a update query, and using LIKE "B09-###" in
the criteria box. But what to put in the Update to box is my problem. The
expression "Replace([YourField],"-","-0")" does not work. Is this because I
use Access97?
"John Spencer" wrote:
> You might use an update query. For your very specific example that could look
> like the following.
>
> UPDATE YourTable
> SET YourField = Replace([YourField],"-","-0")
> WHERE YourField LIKE "B09-###"
>
> ==Create a new query
> ==Add your table
> ==Add your field
> ==Set the criteria under field to be changed to
> LIKE "B09-###"
> ==SELECT Query: Update from the menu
> ==In the Update to "box" under the field enter
> Replace([YourField],"-","-0")
>
> The above assumes you are using Access 2000 or later. And if you are using
> Access 2000 that it is patched to SP-3 level.
>
>
> John Spencer
> Access MVP 2002-2005, 2007-2009
> The Hilltop Institute
> University of Maryland Baltimore County
>
> BlackKnight wrote:
> > In a table I have a textfield containg data like B09-001, B09-002 etc.
> > Now I am almost at B09-999, so I like to insert a "0" so that the data look
> > like B09-0001, B09-0002, B09-0999 etc.
> > How can I do that with a update-query?
> .
>
|
|
0
|
|
|
|
Reply
|
Utf
|
11/19/2009 8:16:01 AM
|
|
There is no REPLACE function in Access 97. That is what the last line of my
first post was meant to point out. I see that I was unclear.
You can accomplish the same thing using a variation on the query
If you are always looking at the exact structure B09-###
UPDATE YourTable
SET YourField = "B09-0" & Right([YourField],3)
WHERE YourField LIKE "B09-###"
If not then
UPDATE YourTable
SET YourField = Left([YourField],Instr(1,[YourField],"-")) & "0" &
Mid([YourField],Instr(1,[YourField],"-")+1)
WHERE YourField LIKE "B09-###"
OR if the "BO9-" is ALWAYS there as the leading characters
UPDATE YourTable
SET YourField = "B09-0" & Mid([YourField],Instr(1,[YourField],"-")+1)
WHERE YourField LIKE "B09-###"
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
BlackKnight wrote:
> I am using Access97.
> I already came as far as using a update query, and using LIKE "B09-###" in
> the criteria box. But what to put in the Update to box is my problem. The
> expression "Replace([YourField],"-","-0")" does not work. Is this because I
> use Access97?
>
>
> "John Spencer" wrote:
>
>> You might use an update query. For your very specific example that could look
>> like the following.
>>
>> UPDATE YourTable
>> SET YourField = Replace([YourField],"-","-0")
>> WHERE YourField LIKE "B09-###"
>>
>> ==Create a new query
>> ==Add your table
>> ==Add your field
>> ==Set the criteria under field to be changed to
>> LIKE "B09-###"
>> ==SELECT Query: Update from the menu
>> ==In the Update to "box" under the field enter
>> Replace([YourField],"-","-0")
>>
>> The above assumes you are using Access 2000 or later. And if you are using
>> Access 2000 that it is patched to SP-3 level.
>>
>>
>> John Spencer
>> Access MVP 2002-2005, 2007-2009
>> The Hilltop Institute
>> University of Maryland Baltimore County
>>
>> BlackKnight wrote:
>>> In a table I have a textfield containg data like B09-001, B09-002 etc.
>>> Now I am almost at B09-999, so I like to insert a "0" so that the data look
>>> like B09-0001, B09-0002, B09-0999 etc.
>>> How can I do that with a update-query?
>> .
>>
|
|
0
|
|
|
|
Reply
|
John
|
11/19/2009 3:07:26 PM
|
|
In the meantime I figured it out myself.
In entered "Left(["MyField];4)+"0"+Right([MyField];3)" in the update to box.
"BlackKnight" wrote:
> I am using Access97.
> I already came as far as using a update query, and using LIKE "B09-###" in
> the criteria box. But what to put in the Update to box is my problem. The
> expression "Replace([YourField],"-","-0")" does not work. Is this because I
> use Access97?
>
>
> "John Spencer" wrote:
>
> > You might use an update query. For your very specific example that could look
> > like the following.
> >
> > UPDATE YourTable
> > SET YourField = Replace([YourField],"-","-0")
> > WHERE YourField LIKE "B09-###"
> >
> > ==Create a new query
> > ==Add your table
> > ==Add your field
> > ==Set the criteria under field to be changed to
> > LIKE "B09-###"
> > ==SELECT Query: Update from the menu
> > ==In the Update to "box" under the field enter
> > Replace([YourField],"-","-0")
> >
> > The above assumes you are using Access 2000 or later. And if you are using
> > Access 2000 that it is patched to SP-3 level.
> >
> >
> > John Spencer
> > Access MVP 2002-2005, 2007-2009
> > The Hilltop Institute
> > University of Maryland Baltimore County
> >
> > BlackKnight wrote:
> > > In a table I have a textfield containg data like B09-001, B09-002 etc.
> > > Now I am almost at B09-999, so I like to insert a "0" so that the data look
> > > like B09-0001, B09-0002, B09-0999 etc.
> > > How can I do that with a update-query?
> > .
> >
|
|
0
|
|
|
|
Reply
|
Utf
|
11/19/2009 3:08:12 PM
|
|
|
5 Replies
151 Views
(page loaded in 0.056 seconds)
Similiar Articles: Inserting a space between characters in a cell - microsoft.public ...Hi I have a column of codes and some are written as below: A2ABC A2BBB A2CBC A2DBD I want them all to has a space after the A2 ie. A2 ABC,... How can I use VBA to insert a char at the current text insertion ...However, I don't want to insert special characters into text fields or combo boxes via copy and paste (apart from anything else, pasting into a combo box does not ... Inserting a period into a string - microsoft.public.access.queries ...into the string before the last two characters of a string unless the string is ... How to insert into SQL table through RDL custom code?... How to insert into SQL table ... Insert ascii into Access - microsoft.public.access.queries ...INSERT INTO test_row SELECT 1, 'This string has an embedded '+CHAR(0 ... Replace ASCII CHARACTER ... How to Insert Into Access 2007 | eHow.com How to Insert Into Access ... inserting symbols - microsoft.public.mac.office.excelHow to Insert Special ALT Characters |Windows character map How to insert special symbols or characters in Windows when they don't show on the keyboard. Subject Line vs Internet Headers - microsoft.public.outlook ...We found out that it's inserting hex 09 characters. I am having the customer look into it. Thanks for your reply. "Diane Poremsky [MVP]" wrote: > it looks ... How to insert a '*' in certain controls when Enter is ...SelStart = iSelStart + 4 -- Regards Tom "Allen Browne" wrote: > Here's a more generic version, that allows you to insert whatever characters > you want at the ... Inserting Foreign Language Symbols - microsoft.public.mac.office ...The best way: Drop down the flag control from the menu bar and open the Character Viewer: you can search for characters by name and insert them in any application ... Characters deleting forward - WHY? - microsoft.public ...Sometimes my OE takes a fit and decides to delete characters forward of the cursor each time I type a new one - when I want to insert a word in an ... Special character in Input Message - Data Validation - microsoft ...However, I can't seem to produce this character using code. Can someone please post an example where I can insert a special character using code? How to Insert the Special Character U+2E24 in OpenOffice | eHow.comWhen editing documents on the computer, it can be frustrating to insert a character into the document that isn't available on a typical keyboard. One such character ... Insert a symbol or special character - Word - Office.comShow All Hide All You can use the Symbol dialog box to insert symbols, such as ¼ and ©, or special characters, such as an em dash (—) or ellipsis (…) that are ... How to Insert a Tab Character In a Cell | eHow.comWhen you are adding data to any of the cells in your spreadsheet you may not always want the text to start the far left end. In some circumstances the formatting of ... Insert symbols and special characters in a worksheet - Excel ...Insert symbols and special characters on a worksheet You can use the Symbol dialog box to enter symbols and characters that are not on your keyboard. Some examples ... How to insert & character or special character into Database using ...To share some of knowledge, work and how-to, trick, tips in Oracle. Mainly focus with Oracle Financials, Oracle Technology, Oracle Business Intelligence. 7/24/2012 9:28:47 PM
|