Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

InStr Query

Status
Not open for further replies.

Hargreavesk

Technical User
Jul 18, 2001
97
GB
Hi,

I have a cheque which converts it's amount from £513.00 to "Five Hundred Thirteen Pounds". I then use the following code:

FullAmount = Me.Amount_in_Words
Position = InStr(FullAmount, "Hundred") + Len("Hundred")
LeftAmount = Left(FullAmount, Position)
RightAmount = Right(FullAmount, Len(FullAmount) - Position)
NewAmount = LeftAmount & "and " & RightAmount
Me.Amount_in_Words = NewAmount

This inserts "And" to make the NewAmount "Five Hundred And Thirteen Pounds"

I would like the InStr feature to search and add "And" after all instances of "Hundred" but it's only doing this after the first.

Does anyone know how I can do this?

Many thanks

Kate
 
Create this as a function and set the field on the check equal to the function.

Public Function AmtInWordsWAnd(AmtInWords as string) as string

your code starting with:

FullAmount = AmtInWords

and ending with AmtInWordsWAnd = NewAmount

Then set your field equal to :

AmountInWordsWAnd(Me.Amount_In_Words)

Amount_In_Words_with_And = AmtInWordsWAnd(Me.Amount_In_Words)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top