Solved

Access lookup on partial string

Posted on 2013-10-30
7
287 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
  • 4
  • 3
7 Comments
 
LVL 61

Expert Comment

by:mbizup
Comment Utility
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
Comment Utility
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
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:txrussianguy
Comment Utility
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
Comment Utility
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
Comment Utility
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 500 total points
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
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…

743 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

8 Experts available now in Live!

Get 1:1 Help Now