from one field write to other field is that posible ?? in access

Hi ! All!
i have table_A with  field_A with 4 numbers  1234, 0123, 7689, or any number combination
but
is the number have an 0 in field_A  i need  to  put in field_B an  1  
the 0 could be in any position.

is that possible ?
GISELA TOWERAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongCommented:
try:

update yourTable set field_B = 1 where instr(field_A, '0' ) > 0

Open in new window

0
GISELA TOWERAuthor Commented:
where i put it?
0
Ryan ChongCommented:
>>where i put it?
you can create a new Query and execute that.

>>is the number have an 0 in field_A  i need  to  put in field_B an  1
This Update SQL statement will update the field_B with a "1" if a "0" was found in the field_A 's value.

or you can tell us "when" and "how" you want your records to be updated.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

GISELA TOWERAuthor Commented:
I mean i could have  8902 , 0234, 4560, the 0 could be in any position
of the 4 digit
0
Ryan ChongCommented:
yup, that's why we are using instr function in the SQL statement to search for the character's location.

for more ref:

MS ACCESS: INSTR FUNCTION
http://www.techonthenet.com/access/functions/string/instr.php
0
GISELA TOWERAuthor Commented:
is 0 is in any of the 4 digit position of field_A  then
1 should be write to field_B
0
Ryan ChongCommented:
>>is 0 is in any of the 4 digit position of field_A  then
>>1 should be write to field_B

exactly... so have you try to run the Update SQL statement that I posted previously?

update yourTable set field_B = 1 where instr(field_A, '0' ) > 0
0
GISELA TOWERAuthor Commented:
how i can do that?
don't know how
0
Ryan ChongCommented:
try to read through this article:

Create and run an update query
https://support.office.com/en-us/article/Create-and-run-an-update-query-9dddc97c-f17d-43f4-a729-35e5ee1e0514

OR directly:

If you're comfortable working with SQL, you can also write an UPDATE statement by using SQL view. To use SQL view, create a blank, new query, and then switch the SQL view.

SQL version: UPDATE statement
https://support.office.com/en-us/article/Create-and-run-an-update-query-9dddc97c-f17d-43f4-a729-35e5ee1e0514#__toc336583665
0
GISELA TOWERAuthor Commented:
ok i did in test table but nothing happens in field_B
testA.pngtestB.pngtestC.png
0
Ryan ChongCommented:
can you show us the values of col A ?
0
GISELA TOWERAuthor Commented:
this is test1 table
with field A and field B

testD.png
0
Ryan ChongCommented:
alternatively, do a select statement and see what locations are returned...

Select a.*, instr( A, '0' ) as location from Test1 as a

Open in new window

0
Ryan ChongCommented:
make sure you click the "! Run" button to run the SQL statement?

(image copied from Internet)
run button
0
GISELA TOWERAuthor Commented:
ok i have an problem
your solution is almost working
but
when the the four digit beging with 0
is not working for that number like 0897 0999
do i have ti change to text format ?
0
Ryan ChongCommented:
what do you get if you run:
 instr( '0897' , '0' )
 instr( '0999' , '0' )

is that 1 is being returned?
0
GISELA TOWERAuthor Commented:
is field A is number format
i write  0022 but just 22 appear
and does not count the 0
so return 0 no the 1  we need  to see
0
Ryan ChongCommented:
i see, so try like this instead...

update Test1 set B = 1 where instr(right('000' & A, 4), '0' ) > 0

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GISELA TOWERAuthor Commented:
Ryan Chong
your solution is rigth

i would like to make another short question to you
you are good !

if a have  5 colums
                      a    b    c    d   e
Record A         1   1          1       = total
but want to count the row total  for record a
the numbers 1 is in short text format
how can i do tthat ?
0
Ryan ChongCommented:
you may try like:
select a + b+ c+ d+ e as total from yourTable

Open in new window

if that doesn't work, then try like:
select val(a) + val(b)+ val(c)+ val(d)+ val(e) as total from yourTable

Open in new window

0
GISELA TOWERAuthor Commented:
the best !
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.