473,394 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Bin type lookup in access similar to vlookup?

I have an application that involves calculating a score based on a number of
defects. Simplified example of the scoring:

No_Defects Score
1-3 A
4-15 B
16-25 C
over 25 X

In Excel this is easy using a vlookup with its bin system

No_Defects Score
0 A
4 B
16 C
25 X

In Excel, if No_defects=5, it will search down column 1 and retrieve the
score corresponding to the last number before the 5, in this case, "B".

I cannot find a way to do this in Access. The closest I have come is to
create a table with all possible numbers of defects and corresponding scores
but this is not workable, especially when considering decimal numbers.

Is there an elegant way to do this using a function or am I pounding my head
against a wall?

Fred


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Nov 13 '05 #1
3 2445
What score if there are no defects?

Something like

Table DefectsScoring
3 columns
Score Lo Hi
A 1 3
B 4 15
C 16 25
X 25 9999999

PARAMETERS thisscore Short;
SELECT Score
FROM DefectsScoring
WHERE ((Lo<=[thisscore]) AND (Hi >=[thisscore]));

Or
2 Columns
Score Hi
A 3
B 15
C 25
X 9999999

SELECT TOP 1 DefectsScoring.Score
FROM DefectsScoring
WHERE Hi>=[thisscore]
ORDER BY DefectsScoring.Hi;

--
Terry Kreft
MVP Microsoft Access
"Fred" <fr**************@wymans.com> wrote in message
news:40********@corp.newsgroups.com...
I have an application that involves calculating a score based on a number of defects. Simplified example of the scoring:

No_Defects Score
1-3 A
4-15 B
16-25 C
over 25 X

In Excel this is easy using a vlookup with its bin system

No_Defects Score
0 A
4 B
16 C
25 X

In Excel, if No_defects=5, it will search down column 1 and retrieve the
score corresponding to the last number before the 5, in this case, "B".

I cannot find a way to do this in Access. The closest I have come is to
create a table with all possible numbers of defects and corresponding scores but this is not workable, especially when considering decimal numbers.

Is there an elegant way to do this using a function or am I pounding my head against a wall?

Fred


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----

Nov 13 '05 #2
Thank you- it's making more sense this way. Is there an easy way to
incorporate this in an unbound control in a form?

Fred

"Terry Kreft" <te*********@mps.co.uk> wrote in message
news:DL********************@karoo.co.uk...
What score if there are no defects?

Something like

Table DefectsScoring
3 columns
Score Lo Hi
A 1 3
B 4 15
C 16 25
X 25 9999999

PARAMETERS thisscore Short;
SELECT Score
FROM DefectsScoring
WHERE ((Lo<=[thisscore]) AND (Hi >=[thisscore]));

Or
2 Columns
Score Hi
A 3
B 15
C 25
X 9999999

SELECT TOP 1 DefectsScoring.Score
FROM DefectsScoring
WHERE Hi>=[thisscore]
ORDER BY DefectsScoring.Hi;

--
Terry Kreft
MVP Microsoft Access
"Fred" <fr**************@wymans.com> wrote in message
news:40********@corp.newsgroups.com...
I have an application that involves calculating a score based on a
number of
defects. Simplified example of the scoring:

No_Defects Score
1-3 A
4-15 B
16-25 C
over 25 X

In Excel this is easy using a vlookup with its bin system

No_Defects Score
0 A
4 B
16 C
25 X

In Excel, if No_defects=5, it will search down column 1 and retrieve the
score corresponding to the last number before the 5, in this case, "B".

I cannot find a way to do this in Access. The closest I have come is to
create a table with all possible numbers of defects and corresponding

scores
but this is not workable, especially when considering decimal numbers.

Is there an elegant way to do this using a function or am I pounding my

head
against a wall?

Fred


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----




-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Nov 13 '05 #3
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Another way to state the comparison in the WHERE clause is:

WHERE [thisscore] BETWEEN Lo AND Hi

===

In a form control you could put a domain function in the control's
ControlSource property. E.g. (ignore line-wrap):

=DLookup("Score", "DefectsScoring", Form!ThisScore & "BETWEEN Lo AND
Hi")

The Form!ThisScore is a reference to the control "ThisScore" on the same
form as the control w/ the DLookup() function.

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQQBc34echKqOuFEgEQKpdACdFJRaHcsRoAT5KClPDcgu1Y fBKJUAoNm4
DTCKPtfDRZ3UmBHQXYvWuiAo
=9inO
-----END PGP SIGNATURE-----
Fred wrote:
Thank you- it's making more sense this way. Is there an easy way to
incorporate this in an unbound control in a form?

Fred

"Terry Kreft" <te*********@mps.co.uk> wrote in message
news:DL********************@karoo.co.uk...
What score if there are no defects?

Something like

Table DefectsScoring
3 columns
Score Lo Hi
A 1 3
B 4 15
C 16 25
X 25 9999999

PARAMETERS thisscore Short;
SELECT Score
FROM DefectsScoring
WHERE ((Lo<=[thisscore]) AND (Hi >=[thisscore]));

Or
2 Columns
Score Hi
A 3
B 15
C 25
X 9999999

SELECT TOP 1 DefectsScoring.Score
FROM DefectsScoring
WHERE Hi>=[thisscore]
ORDER BY DefectsScoring.Hi;

--
Terry Kreft
MVP Microsoft Access


< snip original post >

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Steve P | last post by:
I am creating a report where I have a Unique identifier for each customer. ie 1, 2, 3 etc. The Customer has a name of Joe, Mary, Fred etc. The customers details all come from the one table and...
1
by: Zachary Turner | last post by:
I want to make a Lookup Field based on another Lookup field. In other words, I have this table A with two fields: ID and Name, where ID is an Autonumber and Name is a friendly name. Then I have a...
2
by: Rebecca | last post by:
could someone tell me the correct syntax for using vlookup in visual basic
2
by: JK | last post by:
I have two linked tables. One with several million records that include "price paid". The second with price increments like "Between 1 and 100,000" and "Between 100001 and 200000" etc. Is there...
4
by: keri | last post by:
Hi everybody, I'm very new to access so please treat me with kid gloves! (i'm hopeless with code and macros but enjoying learning). I am loving what it is capable of though, and i'm sure I...
4
by: ritheshtitu1982 | last post by:
Hi, I would like to perform Vlookup in access. Eg. I have two Tables Code table Code --- No { ------- 0 ...
4
by: shreyansghia | last post by:
Hello , Can anyone help me in understanding how do we use Vlookup ( as we use in Excel) in MS access. Thanks much in advance
3
by: =?Utf-8?B?U2NvdHRAQ1c=?= | last post by:
I have a worksheet that has dates in column B and file # in column A. In cell J12, i have this formula =min(B2:B100), in L12, I have a vlookup to return the information in column A that matches the...
11
by: memiles | last post by:
Table 1 Part number, Data, Data1, Data2..... (Part Numer in this table is duplicated multiple times) Table 2 Part Number, Data 3...... (Part Number in this table is not duplicated) I would...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.