Create an If/then equation in Access Feild

Posted on 2004-10-04
Last Modified: 2012-06-27

This is what I am trying to do:  I am importing a field into an Access Db called "BusSegment".  I have another field called "ISO".  The "ISO" field gets populated with people's names.  It is dependent upon the "BusSegment".  What I want to do is setup some kind of equation so the "ISO" field gets AUTOMATICALLY populated with the corresponding "ISO" name when I enter a certain "BusSegment".  How should I go about this?  Thanks....
Question by:jz1english
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +2
LVL 12

Expert Comment

ID: 12219536
If you mean you want to do this in table design, you cannot--Access does not support derived or calculated fields.  

You can do this on a form or you could use a query to update your field.
LVL 12

Expert Comment

ID: 12219549
I should have complete my first sentence above
     Access does not support derived or calculated fields IN TABLES.

Sorry for the lack of clarity.

Author Comment

ID: 12219564
This is basically how the process works.  I get an excel spreadsheet with that contains several fields including the "BusSegment".  I import that spreadsheet into my DB and then use an append query to create a record for each one.  The "ISO" field is not included in this spreadsheet though.  I have to come up with that info.  Instead of me having to input each "ISO" for each record that I import, I want that field to be auto generated based on the "BusSegment".  Is that possible?  Thanks....
Do you have a plan for Continuity?

It's inevitable. People leave organizations creating a gap in your service. That's where Percona comes in.

See how relies on Percona to:
-Manage their database
-Guarantee data safety and protection
-Provide database expertise that is available for any situation

LVL 12

Accepted Solution

pique_tech earned 200 total points
ID: 12219590
Oh, sure, since you're using an append query.  

Say you need to append the value of today's date to BusSegment and save it into the ISO field.  Then in your append query, you'd have
Expr1:  BusSegment & CStr(Date())
Append To:  ISO

Say the BusSegment info is a single alpha character (a, b, c, etc.)  This would take that value, concatenate today's date, and place it into the ISO field:  a10/04/2004, b10/04/2004, etc.

Is this what you mean?

Author Comment

ID: 12219645
I am not sure, you are confusing me with the date example.  Basically, here is what my data is like:

I have several business segments: transactions services, financial, personel.  With each one of these there is a different person handling the issue I put into the db.  for transaction service it is linda, for financial it is larry and personnel it is peggy.  what i need is when i append transaction services into the bussegment feild, linda is automatically entered into the iso field and so on.  does that make sense?  thanks..
LVL 44

Assisted Solution

Arthur_Wood earned 100 total points
ID: 12221269
Is the relationship between BusSegment and ISO defined elsewhere in your database?

For instance, do you have a table which identifies the ISO give the BusSegment?

If so, then it is a relatively straight forward process to add an ISO field to the table you are popluating, and then associate that field with the value in the ISO field in the related table that has the BusSegment from the first record.

Add the ISO field, then in the Design mode of that field, Click on the Lookup Tab, change the Display Control to ComboBox, then on the RowSource line, click on the button at the right with '...'  Choose the Table that has the relationship between ISO and BusSegment.  Set the Column Count to 2, and Set the ColumnWidths to 0";1" (this will 'hide' the first of the 2 columns, and show the second - which has the ISO Name.

See if that gets you what you need.

LVL 12

Expert Comment

ID: 12221310
Do you have a table that pairs your people with your segments?  That would be the first step.

Let's say your imported spreadsheet table is called TemporaryRecords with a field called BusSegment and the table with people and segment is SegmentRepresentative with a field called BusSegment and another field called RepresentativeName.  Then you'd have both tables in your append query design and they'd be joined on BusSegment.  In the query, you could then pull down RepresentativeName and append that value to the ISO field in the destination table.

Is that a little clearer?
LVL 58

Assisted Solution

by:Julian Hansen
Julian Hansen earned 100 total points
ID: 12227009
I am probably missing something here but here goes anyway

You have two choices

1. If you import the excel spreadsheet using code then you can do the assignment there using code

2. If you are importing using access inbuilt import and then using a query to populate another table with the data then in the append query do something like

insert into target (field1, field2, field3, field4) select field1, iif(field2='x',TruePart,FalsePart) + field6 +Mid(field7,2,2) from source

The above is just a sample to demonstrate how to insert values that are composits of other values - but you can modify for your needs

You can also use these in an update statement as well
LVL 58

Expert Comment

by:Julian Hansen
ID: 12227030
Of course there is a blatent error in the above sql statement in that I have specified more fields in the insert then are selected from the source table - but the idea was to illustrate creating composite fields not how an insert statement works. For the pure at heart ...

insert into target (field1, field2) select field1, iif(field2='x',TruePart,FalsePart) + field6 +Mid(field7,2,2) from source

Assisted Solution

doswell earned 100 total points
ID: 12229027
use a join with your appened query.

insert into target (field1, field2, BusSegment, ISO)
select t1.field1, t1.field2, t1.BusSegment, t2.ISO
from ExcelTable t1
inner join ISOTable t2 on t1.BusSegment = t2.BusSegmentID

Where ISOTable  has one row for each BusSegment, and two columns one to match the BusSegment to the impot table, and the second being the ISO (description or what ever you want it to match to)

Expert Comment

ID: 12229029
Access may get picky with thr linking, it's easy to setup in the query design

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Your data is at risk. Probably more today that at any other time in history. There are simply more people with more access to the Web with bad intentions.
Lotus Notes has been used since a very long time as an e-mail client and is very popular because of it's unmatched security. In this article we are going to learn about  RRV Bucket corruption and understand various methods to Fix "RRV Bucket Corrupt…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question