Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Access lookup on partial string

Posted on 2013-10-30
7
Medium Priority
?
302 Views
Last Modified: 2014-04-10
Using Access '07...long time since I've been in Access...I need to do the equivalent of the following from Excel:

use the left 4 characters in a field to go to a table that has 5 versions of those 4 characters, and bring back into the table from which I'm looking, the value in the second field of the lookup table.

Basically, I have a table with a long list of account information (chart of accounts from accounting department).  The start of each account is "10-x" (with 'x' being anything from 4 to 8).  Depending on the 'x', it is either a 'revenue'/'expense'/etc. account type.  I am going to be taking the results of this out of Access and dumping to Excel, for pivoting.  I need that 'account type' designation to come across in the results.  In Excel, I'd simply do a vlookup(left(CELL,4),SHORT_TABLE_WITH_LOOKUP_VALUES,2,false), and I'd have my answer.  Don't know how to replicate that in Access, and can't seem to find the right online searches for answers.
0
Comment
Question by:txrussianguy
[X]
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
  • 3
7 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 39613496
This is aircode, and you'll have to replace table and field names to reflect those in your actual database.

You can do what you are describing by joining your main table with your lookup table in a query:


SELECT MainTable.*, LEFT(MainTable.Account, 4) AS AccountPrefix, LookupTable.AccountTypeDesignation
FROM MainTable INNER JOIN  LookupTable
ON LEFT(MainTable.Account, 4) = LookupTable.AccountTypeAbbreviation

Open in new window

0
 

Author Comment

by:txrussianguy
ID: 39614204
Thanks for this...again, being a bit of a "re-" newbie, I'm lacking the overall context of how this would be used.  Am i putting this as a standalone query, or is this some sort of calculated field formula?  In other words, at which step would I be able to use these results?  What I ultimately am doing is pulling together the following, into a pivottable (for sharing reasons, may have to be done in Excel, though I see now I can in '07 Acc also do one):

Budget listing
Actual listing
This lookup of account type (to use as a filter in my pivot for selecting which portions of above two I want to see)
Some more looked up information from a "project id" table, which gives me certain characteristics of the project id's that are in the budget and actual information

So basically...where is this query coming into play?
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39614227
My suggestion was for a standalone query, to demonstrate the concept.  You can use the query as is and apply the output as needed, or apply the concept in your own context.

Even with your explanation your application is not completely clear so it is hard to provide a more specific answer.  If you are able to post a sample database, it might help.
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

Author Comment

by:txrussianguy
ID: 39614321
Thanks for the offer to teach me how to fish.  Attached is a completely stripped down version.  What I'm after is the ability to pivot with the information from Acct Type of "Account Lookup" table, married with the information from budget table...and then there will be a "Project ID" table, which gives info that is based on "Project #", as well as an 'actual' table, structured exactly like the budget table, but with "actual" in the "Act/Bud" column.

Hope it makes more sense now with a sample.

Thanks again.  Refreshing to have a network of folks that are a) obviously pro's, and b) so responsive.
AS-Budget--14---Copy.accdb
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39615143
Hmm... still not clear.

Can you post a spreadsheet or similar visually showing what your expected output would be... using the tables and data in the sample.

(For the purpose of this question, lets focus on a single topic/query/output goal)
0
 

Author Comment

by:txrussianguy
ID: 39615494
Attached is the very small snapshot.  For a column like 'E' in "IS 11", I don't want to have to populate it with "revenue", "expense", etc.  I want it to know what it's supposed to be.  The data output I get is A-D, so I'm trying to figure out how to get to my pivotable summary table (which has all elements), but with an efficient DB, which doesn't have to actually enter information over and over, but rather does a reference check against tables like "CoA" in this sheet (and project list, and so forth).

Hope now it's finally clearer than dark mud.
historical-actuals--through-Sep-.xlsx
0
 
LVL 61

Accepted Solution

by:
mbizup earned 2000 total points
ID: 39615760
Okay - I think I understand what you are asking, and it is pretty much what I suggested earlier.

Look at the query qryBudget13.  That can be used for reporting purposes.

Then look at frmBudget13 (the form).  That is used for entering data.  You don't need, and shouldn't have lookup fields like account type in your tables... data like that can be looked up on an as-needed basis.

The form is one way to enter data such as the Account Number and have a form automatically display (but not store) the account type during data entry.  The right most textbox displays the account type using a DLookup function call (very similar to your VLookup):
AS-Budget--14---Copy.accdb
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!

Question has a verified solution.

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

This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

721 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