INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Update column based on constraints

Update column based on constraints

(OP)
Hi All,

Want to update a column based on 2 columns at Table level and would like some help.

CODE

Current Table structure: tblCheckId
    RightId text(25), WrongId text(25), RightId_chk text(1)

Indexes in TblCheckId:
Indx1  is RightId+RightId_Chk  in this combination Unique as Yes
Indx2  is WrongId              Unique as Yes

Value in table: tblCheckId 
    RightId	  WrongId       RightId_Chk
    Material1		        Y
    Material1     mtrl1
    Material1     Mtrial1

Gives error in below sql:
ALTER table tblCheckId
ADD constraint (RightId is not null AND 
                WrongId is null references tblcheckid 
                on UPDATE SET RightId_chk ="Y") 

Error: constraint clause


How to UPDATE columnn RightId_Chk to value 'Y' only when
RightId is Not Null and WrongId is null

or is there another way to achieve this condition.


Thanks,

IT-Tech

RE: Update column based on constraints

UPDATE tblCheckId
SET RightId_Chk = 'Y'
WHERE RightId IS NOT NULL
AND WrongId IS NULL

Have fun.

---- Andy

RE: Update column based on constraints

(OP)
Hi All,

Can we store UPDATE command with the table itself ?
That is when a user enters material in column RightId and WrongId is left blank, RightId_Chk is updated to Y.

The UPDATE command should run by itself like a trigger in access 2010.

IT-Tech

RE: Update column based on constraints

(OP)
Hi All,

Thanks, it is working.

In Access 2010 you go to design mode, In design mode select the field getting updated e.g. rightid, than click icon Create Data Macro, select Before change and use the condition.

Thanks for all you help.

IT-Tech

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close