Create an If/then equation in Access Feild

Hello,

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....
jz1englishAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
pique_techConnect With a Mentor Commented:
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?
0
 
pique_techCommented:
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.
0
 
pique_techCommented:
I should have complete my first sentence above
     Access does not support derived or calculated fields IN TABLES.

Sorry for the lack of clarity.
0
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

 
jz1englishAuthor Commented:
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....
0
 
jz1englishAuthor Commented:
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..
0
 
Arthur_WoodConnect With a Mentor Commented:
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.

AW
0
 
pique_techCommented:
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?
0
 
Julian HansenConnect With a Mentor Commented:
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
0
 
Julian HansenCommented:
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
0
 
doswellConnect With a Mentor Commented:
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)
0
 
doswellCommented:
Access may get picky with thr linking, it's easy to setup in the query design
0
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.

All Courses

From novice to tech pro — start learning today.