"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