Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to add data into a field based of the value of another

Status
Not open for further replies.

VhbuiA

MIS
Oct 6, 2005
22
US
Hi, I have done a lot of research and have not quite found the solution to a problem I am having...hope someone can point me into the right direction.

I created a table using VBA to pull data from an Excel spreadsheet into my db. However, I only require select fields for the purpose of the db. So I then created a event that only captures the fields I need into a new table. The reason why I am doing this is to keep the original source data in tact. OK, so here's the problem: After the data is pulled in the SQL event, I want it to take the values of Field X (populated after the event) and determine if it is a specific value (say "YES"), then Field Y = "CASH", all others "CREDIT"

Is this possible to do? Any help is greatly appreciated! Thanks!
 
You can run two update queries...

Code:
UPDATE YourTable SET YourTable.FieldY = 'CASH' WHERE YourTable.FieldX = 'YES'

Code:
UPDATE YourTable SET YourTable.FieldY = 'CASH' WHERE YourTable.FieldX <> 'YES'

You can also do it through DAO, but this is quicker and less painful if it does what you need.
 
Sorry, that second query should have been setting the field to CREDIT, but I'm sure you figured that out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top