更改表格中的很多单词 [英] Change a lot of words in a table

查看:76
本文介绍了更改表格中的很多单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!


A有问题。我有一个包含

ID,Brend,Model,Color,Price的表格。

Color字段的颜色如下:YELLOW / BLACK / RED,YELLOW / RED,BLUE,

BLUE / NAVY / RED / CHARCOAL。

现在我想像这样缩短它们

YELLOW-> YEL,BLACK-> ; BLK,WHITE-> WHT ......

这样颜色区域看起来就像这个YEL / BLK / RED等等。

请帮帮忙!


Marko

Hi!

A have a problem. I have a table containing
ID,Brend,Model,Colour,Price.
The Colour field has colours like: YELLOW/BLACK/RED, YELLOW/RED, BLUE,
BLUE/NAVY/RED/CHARCOAL.
Now i would like to shorten them like this
YELLOW->YEL,BLACK->BLK,WHITE->WHT...
so that the colour field would look like this YEL/BLK/RED and so on.
Please help!

Marko

推荐答案

Marko -


paramArray非常适用于您需要检查的数量为
的项目。对于大量的b
记录来说可能有点慢,但由于这似乎是一次性拍摄,所以很可能值得等待。

********************代码***************** ***

公共函数ReplHue(pStr As String,ParamArray varMyVals()As

Variant)As String

''**** *******************************************

''Re :
http://groups.google .com / group / comp .... access / browse_

frm / thread / 077757357b36d7da / 44153ba1796871c6?hl = en#44153ba1796871c6

''目的:用另一个名称替换

''字符串的指定部分。

''编码:raskew

''输入:来自debug(立即)窗口

''? replHue(Green / White / Red / Black,Yellow,Yel,

Black,Blk,White,Wht等。 )

''输出:绿色/白色/红色/ Blk

''******************** ***********************


Dim i As Integer

Dim n As整数

Dim strHold As String


strHold = pStr


for i = 0 To UBound(varMyVals)Step 2


n = InStr(strHold,varMyVals(i))


如果n> 0然后


strHold =左(strHold,n - 1)& varMyVals(i + 1)&

Mid(strHold,n + Len(varMyVals(i)))


结束如果


下一页我是


ReplHue = strHold


结束功能


* *******************结束代码********************


您可以按照评论中的说明进行测试。一旦满意其

操作,

并修改了满足您需求的选项,请创建一个测试查询,其中包含

a计算字段,显示结果后应用ReplHue,例如

**********查询开始**********

SELECT

tblColor2.ID

,tblColor2.Color

,replHue([color],Yellow,Yel,Black,Blk)。 ,白色,白色)AS

固定

来自

tblColor2;

** ********查询结束************

(必要时替换表和字段名称)


最后,在备份你的表!!!后,使用

创建一个更新查询,如上所示。


HTH - Bob

Marko -

A paramArray works pretty well in a situation where you have a number
of items to check for. It might be a tad slow for a large number of
records, but since this appears to be a one-time shot, it well may be
worth the wait.

******************** the code ********************
Public Function ReplHue(pStr As String, ParamArray varMyVals() As
Variant) As String
''*******************************************
''Re:
http://groups.google.com/group/comp....access/browse_
frm/thread/077757357b36d7da/44153ba1796871c6?hl=en#44153ba1796871c6
''Purpose: Replace specified portion of
'' string with another designation.
''Coded by: raskew
''Inputs: from debug (immediate) window
'' ? replHue("Green/White/Red/Black", "Yellow", "Yel",
"Black", "Blk", "White", "Wht")
''Output: Green/Wht/Red/Blk
''*******************************************

Dim i As Integer
Dim n As Integer
Dim strHold As String

strHold = pStr

For i = 0 To UBound(varMyVals) Step 2

n = InStr(strHold, varMyVals(i))

If n > 0 Then

strHold = Left(strHold, n - 1) & varMyVals(i + 1) &
Mid(strHold, n + Len(varMyVals(i)))

End If

Next i

ReplHue = strHold

End Function

******************** end code ********************

You can test it as shown in the comments. Once satisfied with its
operation,
with the options modified to meet your needs, create a test query with
a calculated field showing the results after applying ReplHue, e.g.
**********query starts**********
SELECT
tblColor2.ID
, tblColor2.Color
, replHue([color],"Yellow","Yel","Black","Blk","White","Wht") AS
Fixed
FROM
tblColor2;
**********query ends************
(replace table and field names as necessary)

Finally, after backing-up your table!!!, create an update query using
the logic shown above.

HTH - Bob


一种方法是遍历该表中的字段并一次更新一块

。使用SPLIT将值分解为单个值,然后使用
读取它们并将其分出。然后在完成后重新组装。

one way is to loop through the field in that table and update a piece
at a time. Use SPLIT to break out the values into single values and
then read them and sub out. then reassemble the thing when you''re done.


一种方法是遍历该表中的字段并更新一块
$一次b $ b。使用SPLIT将值分解为单个值,然后使用
读取它们并将其分出。然后当你完成这件事时重新组装。


当然,如果你以更规范化的方式存储它,那么这个

将是必要的。您可以运行一些更新查询,并用它完成



one way is to loop through the field in that table and update a piece
at a time. Use SPLIT to break out the values into single values and
then read them and sub out. then reassemble the thing when you''re
done.

of course, if you stored this in a more normalized way, none of this
would be necessary at all. You could run a few update queries and be
done with it.


这篇关于更改表格中的很多单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆