Solved

Create an If/then equation in Access Feild

Posted on 2004-10-04
11
384 Views
Last Modified: 2012-06-27
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....
0
Comment
Question by:jz1english
  • 4
  • 2
  • 2
  • +2
11 Comments
 
LVL 12

Expert Comment

by:pique_tech
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.
0
 
LVL 12

Expert Comment

by:pique_tech
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.
0
 

Author Comment

by:jz1english
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....
0
 
LVL 12

Accepted Solution

by:
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?
0
 

Author Comment

by:jz1english
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..
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 44

Assisted Solution

by:Arthur_Wood
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.

AW
0
 
LVL 12

Expert Comment

by:pique_tech
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?
0
 
LVL 52

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
0
 
LVL 52

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
0
 
LVL 2

Assisted Solution

by:doswell
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)
0
 
LVL 2

Expert Comment

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

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
Read about achieving the basic levels of HRIS security in the workplace.
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now