G
Gary
I have a text box which contains address information and the company
reference number. Sometimes the address is 3 lines long, sometimes the
address is four lines long, which means either of the two following
examples can occur.
name of company
Add1
Add2
Add3
Company No.
or...
name of company
Add1
Add2
Add3
Add4
Company No.
What I need to do is put each address line in its own field, and put
the company number in its own field. My idea is to check to see if
vartext(4) (the fifth line from the text box) starts with the phrase
'Company No' , if it does then it is the company number line and the
company number should be extracted from this line and put in the
company number field. This implies that address data for this record is
3 lines long, and so I can assign vartext(1), (2), and (3) to their
respective address fields in my form.
If however vartext(4) is does not start with the phrase 'Company No.'
then it will be an address line and should be put into the 4th address
field. In this case the next line will be the company number, so I will
assign vartext(1), (2), (3) and (4) as address fields and vartext(5) as
the company number.
I have the following code to do this, but it's not working.. can some
clever person spot my mistake?
If Left$(varText(4), 10) = "Company No" Then
companynumber = varText(4) ' assign the fifth line to
the variable stringcompanynumber
companyinteger = Mid(companynumber, 13) ' assign the 'number' out
of stringcompanynumber to companynumber
Me.Company_Reg_No.Value = companyinteger ' insert
companynumber into 'company reg no' field.
Else
Me.address4.Value = varText(4)
companynumber = varText(5) ' assign the fifth line to the
variable stringcompanynumber
companyinteger = Mid(companynumber, 13) ' assign the 'number' out of
stringcompanynumber to companynumber
Me.Company_Reg_No.Value = companyinteger ' insert companynumber
into 'company reg no' field.
End If
companynumber = varText(5) ' assign the fifth line to the
variable stringcompanynumber
companyinteger = Mid(companynumber, 13) ' assign the 'number' out of
stringcompanynumber to companynumber
Me.Company_Reg_No.Value = companyinteger ' insert companynumber
into 'company reg no' field.
Thanks in advance,
Gary-
reference number. Sometimes the address is 3 lines long, sometimes the
address is four lines long, which means either of the two following
examples can occur.
name of company
Add1
Add2
Add3
Company No.
or...
name of company
Add1
Add2
Add3
Add4
Company No.
What I need to do is put each address line in its own field, and put
the company number in its own field. My idea is to check to see if
vartext(4) (the fifth line from the text box) starts with the phrase
'Company No' , if it does then it is the company number line and the
company number should be extracted from this line and put in the
company number field. This implies that address data for this record is
3 lines long, and so I can assign vartext(1), (2), and (3) to their
respective address fields in my form.
If however vartext(4) is does not start with the phrase 'Company No.'
then it will be an address line and should be put into the 4th address
field. In this case the next line will be the company number, so I will
assign vartext(1), (2), (3) and (4) as address fields and vartext(5) as
the company number.
I have the following code to do this, but it's not working.. can some
clever person spot my mistake?
If Left$(varText(4), 10) = "Company No" Then
companynumber = varText(4) ' assign the fifth line to
the variable stringcompanynumber
companyinteger = Mid(companynumber, 13) ' assign the 'number' out
of stringcompanynumber to companynumber
Me.Company_Reg_No.Value = companyinteger ' insert
companynumber into 'company reg no' field.
Else
Me.address4.Value = varText(4)
companynumber = varText(5) ' assign the fifth line to the
variable stringcompanynumber
companyinteger = Mid(companynumber, 13) ' assign the 'number' out of
stringcompanynumber to companynumber
Me.Company_Reg_No.Value = companyinteger ' insert companynumber
into 'company reg no' field.
End If
companynumber = varText(5) ' assign the fifth line to the
variable stringcompanynumber
companyinteger = Mid(companynumber, 13) ' assign the 'number' out of
stringcompanynumber to companynumber
Me.Company_Reg_No.Value = companyinteger ' insert companynumber
into 'company reg no' field.
Thanks in advance,
Gary-