Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 425
  • Last Modified:

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....
0
jz1english
Asked:
jz1english
  • 4
  • 2
  • 2
  • +2
4 Solutions
 
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
 
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
pique_techCommented:
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
 
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_WoodCommented:
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 HansenCommented:
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
 
doswellCommented:
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now