By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,728 Members | 2,490 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,728 IT Pros & Developers. It's quick & easy.

Access 2002: How to select only first two numbers

P: n/a
D.M
Hye,
I have a form with 8 telephone number fields.
I want to take only first two numbers and make a new field called network
group.
Please can you help me?
Thanks
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
DFS
"D.M" <ma*****@hotmail.com> wrote in message
news:bq**********@ariane.blic.net...
Hye,
I have a form with 8 telephone number fields.
I want to take only first two numbers and make a new field called network
group.
Please can you help me?
Thanks

Assume the fields are named txtPhone1, txtPhone2, ... txtPhone8

Not clear on what "the first two numbers" means:

A) Is it all digits in the first 2 phone number fields? If so, place this
code in the AfterUpdate or Exit event of txtPhone1 and txtPhone2

if not isnull(me.txtPhone1) and not isnull(me.txtPhone2) then
me.txtNetworkGroup = left(me.txtPhone1,2) & left(me.txtPhone2,2)
endif
B) Is it the first 2 digits from each of the 8 phone number fields? If so,
place this code in a click button

for i = 1 to 8
if isnull(me("txtPhone" & i)) or len(me("txtPhone" & i)) < 2 then
msgbox "All phone numbers must be completed"
exit sub
endif
next i

me.txtNetworkGroup = ""
for i = 1 to 8
me.txtNetworkGroup = me.txtNetworkGroup & left(me("txtPhone" & i),2)
next i

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.