473,385 Members | 1,838 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,385 software developers and data experts.

Using the alphabet

Hi all...

I'm passing the value of txtSurname to a function, which returns the correct
'Team' to txtTeam depending on the 'alphabetic' value of txtSurname e.g.
All surname names between: A* - BAR* = Team 1
BAS* - COL* = Team 2
COM* - Z* = Team 3
Can someone drum up a quick example of the best way to do this?

Thanks,
Paul
May 27 '06 #1
6 2195
Create a column with 2 fields:
TeamID Number primary key
NameStart Text

Enter the records:
1 A
2 Bas
3 Com
and so on.

Download the ELookup() function from:
http://allenbrowne.com/ser-42.html

You can now get the team number from this expression:
=ELookup("TeamID", "tblTeam", """" & [Surname] & """ >= [NameStart]",
"NameStart DESC")

If you want something more sophistocated, see Tom Ellison's article:
Lookup in a range of values in a query
at:
http://allenbrowne.com/ser-58.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Paul Wagstaff" <pa**********@blueyonder.co.uk> wrote in message
news:0B******************@fe1.news.blueyonder.co.u k...

I'm passing the value of txtSurname to a function, which returns the
correct 'Team' to txtTeam depending on the 'alphabetic' value of
txtSurname e.g.
All surname names between: A* - BAR* = Team 1
BAS* - COL* = Team 2
COM* - Z* = Team 3
Can someone drum up a quick example of the best way to do this?

Thanks,
Paul

May 27 '06 #2
Thanks Allen. I may well come back to this at some point. For now, i'll
continue with what i have which is...

If strIn < "BAS" Then 'A -BAR
AssignTo = "Group 1"
ElseIf strIn > "BAR*" And strIn < "BROX" Then 'BAS -BROW
AssignTo = "Group 2"
........etc all the way to Z*

Else
AssignTo = "Error"
End If

The alphabet variables aren't likely to change, so I think this is will
suffice. Unless I'm making some serious error with this method?

Paul.

"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:44**********************@per-qv1-newsreader-01.iinet.net.au...
Create a column with 2 fields:
TeamID Number primary key
NameStart Text

Enter the records:
1 A
2 Bas
3 Com
and so on.

Download the ELookup() function from:
http://allenbrowne.com/ser-42.html

You can now get the team number from this expression:
=ELookup("TeamID", "tblTeam", """" & [Surname] & """ >= [NameStart]",
"NameStart DESC")

If you want something more sophistocated, see Tom Ellison's article:
Lookup in a range of values in a query
at:
http://allenbrowne.com/ser-58.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Paul Wagstaff" <pa**********@blueyonder.co.uk> wrote in message
news:0B******************@fe1.news.blueyonder.co.u k...

I'm passing the value of txtSurname to a function, which returns the
correct 'Team' to txtTeam depending on the 'alphabetic' value of
txtSurname e.g.
All surname names between: A* - BAR* = Team 1
BAS* - COL* = Team 2
COM* - Z* = Team 3
Can someone drum up a quick example of the best way to do this?

Thanks,
Paul


May 27 '06 #3
"Paul Wagstaff" <pa**********@blueyonder.co.uk> wrote in
news:Vd*******************@fe1.news.blueyonder.co. uk:
Thanks Allen. I may well come back to this at some point. For
now, i'll continue with what i have which is...

If strIn < "BAS" Then 'A -BAR
AssignTo = "Group 1"
ElseIf strIn > "BAR*" And strIn < "BROX" Then 'BAS -BROW
AssignTo = "Group 2"
.......etc all the way to Z*

Else
AssignTo = "Error"
End If

The alphabet variables aren't likely to change, so I think
this is will suffice. Unless I'm making some serious error
with this method?

Paul.

Firstly, the asterisk is wrong. (> "BAR*") It only works as a
wildcard with the LIKE keyword, not with >. "BAR A" is >
"bar"

Secondly, you don't even need to test again for the > condition
The elseif construction has already determined that your string
is less that BAS. just test for the upper limit, until the last
breakpoint, then let a simple ELSE handle those.

Thirdly, you shouldn't store "Group 2"
all you need is the 2, stored as a number.
If you try to sort on the "Group x" Column, you will get
confused because the order will be
GROUP 1
GROUP 10
GROUP 12
GROUP 2
GROUP 3

Add the word GROUP as a label in the form or report.

"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:447861a7$0$3626$5a62ac22@per-qv1-newsreader- 01.iinet.net.a u...
Create a column with 2 fields:
TeamID Number primary key
NameStart Text

Enter the records:
1 A
2 Bas
3 Com
and so on.

Download the ELookup() function from:
http://allenbrowne.com/ser-42.html

You can now get the team number from this expression:
=ELookup("TeamID", "tblTeam", """" & [Surname] & """ >=
[NameStart]",
"NameStart DESC")

If you want something more sophistocated, see Tom Ellison's
article:
Lookup in a range of values in a query
at:
http://allenbrowne.com/ser-58.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Paul Wagstaff" <pa**********@blueyonder.co.uk> wrote in
message
news:0B******************@fe1.news.blueyonder.co.u k...

I'm passing the value of txtSurname to a function, which
returns the correct 'Team' to txtTeam depending on the
'alphabetic' value of txtSurname e.g.
All surname names between: A* - BAR* = Team 1
BAS* - COL* =
Team 2
COM* - Z*
= Team 3
Can someone drum up a quick example of the best way to do
this?

Thanks,
Paul




--
Bob Quintal

PA is y I've altered my email address.
May 27 '06 #4
Bob Quintal <rq******@sympatico.ca> wrote in
news:Xn**********************@207.35.177.135:

Firstly, the asterisk is wrong. (> "BAR*") It only works as a
wildcard with the LIKE keyword, not with >. "BAR A" is >
"bar"

Secondly, you don't even need to test again for the > condition The elseif construction has already determined that your string is less that BAS. just test for the upper limit, until the last breakpoint, then let a simple ELSE handle those.

Thirdly, you shouldn't store "Group 2"
all you need is the 2, stored as a number.
If you try to sort on the "Group x" Column, you will get
confused because the order will be
GROUP 1
GROUP 10
GROUP 12
GROUP 2
GROUP 3

Add the word GROUP as a label in the form or report.

After reflection, I'd replace the IF/ELSEIF/ELSE construct with
SELECT CASE strIn
case < "BAS"
assignTo = 1
case < "BROX"
case else
end select

It's faster.
--
Bob Quintal

PA is y I've altered my email address.
May 27 '06 #5
Thanks Bob.

I started using a Select and not using wildcards, but I ran into some
problems if a surname was 'Bar' etc. As you suggest, just testing for the
upperbound value works fine. Many thanks, I suspected my method was flawed.

Point taken about sorting, but it's not a priority for now. The 'Assinged
To' teams aren't sequential anyway - some are just strings - 'Belfast' -
etc. I could (and may in future) create a 1-M table of these, including the
separator points (Bar; Group 1 etc) which will allow the users flexibility
to modify these. Then I'll need a way to ensure there no gaps (i.e. Bar,
Bat)

If I can just find an extra day somewhere between Tuesday and Wednesady,
I'll have time to implement this.

Paul
"Bob Quintal" <rq******@sympatico.ca> wrote in message
news:Xn**********************@207.35.177.135...
Bob Quintal <rq******@sympatico.ca> wrote in
news:Xn**********************@207.35.177.135:

Firstly, the asterisk is wrong. (> "BAR*") It only works as a
wildcard with the LIKE keyword, not with >. "BAR A" is >
"bar"

Secondly, you don't even need to test again for the >

condition
The elseif construction has already determined that your

string
is less that BAS. just test for the upper limit, until the

last
breakpoint, then let a simple ELSE handle those.

Thirdly, you shouldn't store "Group 2"
all you need is the 2, stored as a number.
If you try to sort on the "Group x" Column, you will get
confused because the order will be
GROUP 1
GROUP 10
GROUP 12
GROUP 2
GROUP 3

Add the word GROUP as a label in the form or report.

After reflection, I'd replace the IF/ELSEIF/ELSE construct with
SELECT CASE strIn
case < "BAS"
assignTo = 1
case < "BROX"
case else
end select

It's faster.
--
Bob Quintal

PA is y I've altered my email address.

May 28 '06 #6
"Paul Wagstaff" <pa**********@blueyonder.co.uk> wrote in
news:fn******************@fe1.news.blueyonder.co.u k:
Thanks Bob.

I started using a Select and not using wildcards, but I ran
into some problems if a surname was 'Bar' etc. As you suggest,
just testing for the upperbound value works fine. Many thanks,
I suspected my method was flawed.

Point taken about sorting, but it's not a priority for now.
The 'Assinged To' teams aren't sequential anyway - some are
just strings - 'Belfast' - etc. I could (and may in future)
create a 1-M table of these, including the separator points
(Bar; Group 1 etc) which will allow the users flexibility to
modify these. Then I'll need a way to ensure there no gaps
(i.e. Bar, Bat)

If I can just find an extra day somewhere between Tuesday and
Wednesady, I'll have time to implement this.

Paul
Just testing upper bound and sorting the list alphabetically
will ensure that there are no gaps.
"Bob Quintal" <rq******@sympatico.ca> wrote in message
news:Xn**********************@207.35.177.135...
Bob Quintal <rq******@sympatico.ca> wrote in
news:Xn**********************@207.35.177.135:

Firstly, the asterisk is wrong. (> "BAR*") It only works as
a wildcard with the LIKE keyword, not with >. "BAR A" is
> "bar"

Secondly, you don't even need to test again for the >

condition
The elseif construction has already determined that your

string
is less that BAS. just test for the upper limit, until the

last
breakpoint, then let a simple ELSE handle those.

Thirdly, you shouldn't store "Group 2"
all you need is the 2, stored as a number.
If you try to sort on the "Group x" Column, you will get
confused because the order will be
GROUP 1
GROUP 10
GROUP 12
GROUP 2
GROUP 3

Add the word GROUP as a label in the form or report.

After reflection, I'd replace the IF/ELSEIF/ELSE construct
with SELECT CASE strIn
case < "BAS"
assignTo = 1
case < "BROX"
case else
end select

It's faster.
--
Bob Quintal

PA is y I've altered my email address.



--
Bob Quintal

PA is y I've altered my email address.
May 28 '06 #7

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

Similar topics

2
by: Kyle | last post by:
Got a tough one here for you SQL junkies. I'm working on a website (in ASP) for a national greek/college organization. All it's college chapters have greek chapter names, i.e. Alpha Chapter,...
5
by: Stefan Krah | last post by:
Hello, I am currently writing code where it is convenient to convert char to int . The conversion function relies on a character set with contiguous alphabets. int set_mesg(Key *key, char...
12
by: one | last post by:
greetings i am just wondering if some expert here can either show me how to do this or point me to the right direction (url... i want to use c# to generate a list of alphabet e.g A B C ... AA...
8
by: Jack Addington | last post by:
I want to scroll through the alphabet in order to scroll some data to the closest name that starts with a letter. If the user hits the H button then it should scroll to the letter closest to H. ...
31
by: Joe Smith | last post by:
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789" " " "!#%^&*()-_" "+=~\|;:\'" "\"{},.<>/\?" "\a\b\f\n\r\t\v\\" Do the above string literals comprise an alphabet for C?...
89
by: Cuthbert | last post by:
After compiling the source code with gcc v.4.1.1, I got a warning message: "/tmp/ccixzSIL.o: In function 'main';ex.c: (.text+0x9a): warning: the 'gets' function is dangerous and should not be...
12
by: paitoon | last post by:
Hi, I got a little bit problem about search result in my site. When i put the keyword and click on search ....everything work fine i got the correct result but they not order by the keyword,but...
20
by: geebanga88 | last post by:
HI i have a method that is supose to store the alphabet in an array however dont think that it is being added to the array. public static void GetAlphabet (char alphabet) { int...
3
by: sivadhanekula | last post by:
Hi all I am working on excel, Macros with vb6....When I was writing the for loop I got stuck with getting the next alphabet...Like I need to extract the data from a database and I need to split...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
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...

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.