473,796 Members | 2,558 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2463
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.newsgroup s.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*********@mp s.co.uk> wrote in message
news:DL******** ************@ka roo.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.newsgroup s.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:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

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

iQA/AwUBQQBc34echKq OuFEgEQKpdACdFJ RaHcsRoAT5KClPD cgu1YfBKJUAoNm4
DTCKPtfDRZ3UmBH QXYvWuiAo
=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*********@mp s.co.uk> wrote in message
news:DL******** ************@ka roo.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
3893
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 some of the customers have partners which are also customers in their own right and have the unique identifiers. For examaple: Fred is customer 1 who has a partner, Mary, who is customer 23. On my report I have the customers details in...
1
3369
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 table B which links to A via a Lookup Field so that I can select the friendly name from combo box. Now, I want to have a table C which links to table B via a lookup field, and only displays the items which are selected in some combo box of some...
2
494
by: Rebecca | last post by:
could someone tell me the correct syntax for using vlookup in visual basic
2
1219
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 some way to link them so that I can sum and count by increment? Kinda like Excel's vlookup function with a "false" at the end so it looks up the next value?
4
1359
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 haven't scratched the surface. I have a beginners book & have read many posts, and help files but i am still stuck. I am looking to use the equivalent of a Vlookup function from excel, however I am sure there will be a better way to do this.
4
19989
by: ritheshtitu1982 | last post by:
Hi, I would like to perform Vlookup in access. Eg. I have two Tables Code table Code --- No { ------- 0 } ------- 1
4
1773
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
1330
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 date =vlookup(J12,A2:B100,1,0). I receive a #name error. Any ideas?
11
4456
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 like to create a new table
0
9680
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9528
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10456
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10174
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5442
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5575
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2926
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.