right or left in query?

sasolini

Registered User.
Local time
Today, 03:31
Joined
Dec 27, 2004
Messages
61
hey,

Is it posible to somehow intigrate this code or some other code that would do the same in to query?

code:
str1 = Right(Me.Text1, InStr(Me.Text1, "Ex") + 2)

I have a table1 with filed "EXZ" and that field contain some data like "7.5/400/Eex de IICT4" now i would like to run an update query on that table and update field "EXZ" from "7.5/400/Ex de IICT4" to "Eex de IICT4". The last part of the data is not allways the same but it does allways start with "Ex"! So is that even posible to do with query or do i have tu use a macro or what?

THX
 
I think this is what you are trying to do.

Off the top of my head the SQL should be something like the below, it will update the fields to Right(Field, InStr(Me.Text1, "Ex") + 2) but only where the field contins "ex", be careful though as this will replace anything with Ex in the field, you might be better off looking for "/Ex" in the InStr.

UPDATE Table SET Field = Right(Field, InStr(Me.Text1, "Ex") + 2) WHERE (InStr(Me.Text1, "Ex") <> 0)

Is this what you mean?

Stu
 
hey,

i try with UPDATE Table SET Field = Right(Field, InStr(Field, "Ex") + 2) WHERE (InStr(Field.Text1, "Ex") <> 0)

And the problem is that my records are not all the same left of the "Ex". Some have more some less characters and that i dont get allways the same resoult :confused: So does anyone have any more ideas?

Exampels of my records:

"7.5/400/Ex de II CT4"
"0.75/400/Ex de II AT 4"
"7/400/Ex de II CS 4"
 
try:-

UPDATE Table SET Field = Right(Field, Len(Field) -InStr(Field, "Ex") + 2) WHERE (InStr(Field.Text1, "Ex") <> 0)

Peter
 

Users who are viewing this thread

Back
Top Bottom