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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hello Everyone Ok I have a line

Status
Not open for further replies.

gator9

Technical User
May 17, 2002
162
US
Hello Everyone

Ok I have a line of code here that is designed to take the amount out of a field and put it in another field without the decimal being in the amount. The problem is that when this happens with an amount that is say [$240.50] or [$240.00] it shows up like [2405], and [240] how can I get it to make sure the [00] ceros are added at the end.

Me.MicrPA = Replace([PaymentAmount], ".", "", 1)

Sincerely,

Charles
 
use the Right function and check for 2 0s and if they are add them after ur replace conversion
 
Do you have and example: Also it is ether 2 0s or 1 0 that causes the problem.

Sincerely,

Charles
 
Dim StrVar
If Right(PaymentAmount,1) = "0" Then strVar= "0"
If Right(PaymentAmount,2) = "00" Then strVar= "00"

Me.MicrPA = Me.MicrPA & strVar
 
Thanks for all your help, but can you look at the code below and tell me if it is possible to do a public funiction that would do what I need as in pop the field via =MicrPA([PaymentAmount])

Public Function MicrPA(ByVal strDataToEncode As String)
Dim StrVar
If Right(PaymentAmount, 1) = "." Then StrVar = ""
If Right(PaymentAmount, 1) = "0" Then StrVar = "0"
If Right(PaymentAmount, 2) = "00" Then StrVar = "00"
MicrPA = MicrPA & StrVar
End Function

Thanks A LOT

Sincerely,

Charles
 
Public Function ChangeMicrPA(ByVal strDataToEncode As String)as String
Dim StrVar
If Right(strDataToEncode, 1) = "0" Then StrVar = "0"
If Right(strDataToEncode, 2) = "00" Then StrVar = "00"
ChangeMicrPA = StrVar
End Function
MicrPA=MicrPa & ChangeMicrPA(PaymentAmount)




 
Get an error and debug message when it exe. Also the decimal line of code is not in there.


Sincerely,

Charles
 
Public Function ChangeMicrPA(ByVal strDataToEncode As String)as String
Dim StrVar
StrVar=""

If Len(strDataToEncode)>0 Then
If Right(strDataToEncode, 1) = "." Then StrVar = ""
If Right(strDataToEncode, 1) = "0" Then StrVar = "0"
If Right(strDataToEncode, 2) = "00" Then StrVar = "00"
ChangeMicrPA = StrVar
End If
End Function
MicrPA=MicrPa & ChangeMicrPA(PaymentAmount)

make sure paymentamount is a string and a valid one at that ie len is more than 0
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top