"Paul Wagstaff" <paulwagstaff@blueyonder.co.uk> wrote in
news:Vd0eg.12345$8W1.10224@fe1.news.blueyonder.co. uk:
[color=blue]
> 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.[/color]
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.
[color=blue]
>
> "Allen Browne" <AllenBrowne@SeeSig.Invalid> wrote in message
> news:447861a7$0$3626$5a62ac22@per-qv1-newsreader-[/color]
01.iinet.net.a[color=blue]
> u...[color=green]
>> 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" <paulwagstaff@blueyonder.co.uk> wrote in
>> message
>> news:0BYdg.11717$8W1.7222@fe1.news.blueyonder.co.u k...[color=darkred]
>>>
>>> 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[/color]
>>
>>[/color]
>
>
>[/color]
--
Bob Quintal
PA is y I've altered my email address.