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!

Remove Decimal

Status
Not open for further replies.

gator9

Technical User
May 17, 2002
162
US
Hello Everyone:

Here is a good brain bust at least for me. I have two fields one is named [PaymentAmount] the other is [MicrPA]. This is what I want to be able to do. I want to onClick copy the amount from [PaymentAmount] field to [MicrPA] but here is the thing I want it to delete the decimal from the amount when the transaction takes place. Example: When it copy’s say (20.00) from [PaymentAmount] and puts it on [MicrPA] it should look like this (2004). Any help!

Sincerely,

Charles
 
this might be a little clunky but should get you there. Have your onclick call a function in which you use the split function on the decimal to parse the dollars from the cents and then concatenate them back together under the new variable name and implant the data into the new field.


split syntax is like this:
varname = Split(variable, ",", -1, 1)
where the comma is you'd change to the .
the -1 and 1 are the number of characters either side (I think, check me on that). if it's always a set number you could use just a 2 for example otherwise you'll have to do a check on the length of the variable coming in like this:
len(varname)
hth
mb

"Where's the Ka-Boom? There's supposed to be an Earth-shattering Ka-Boom!"
Marvin the Martian
 
I created a field [MicrPA] with controll source =MicrPA([TotalPlus])

and the public funtion below but I get an error in the field. I think I am close and if I can modifi the public function to work properly with the control source this will be perfect for what I am trying to do.

Public Function MicrPA(ByVal strString As _
String) As String
'Used with all text boxes on form
'except memo control
strString = Replace(strString, ".", "", _
1, -1, vbTextCompare)
'Spaces stripped
strString = StrConv(strString, _
vbProperCase)
'First letter capitalized
MicrPA = strString
'Cleaned-up string replaces old string
End Function


Sincerely,

Charles
 
Got It

Here is the code that works with the on click event

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

Works Great

Thanks ALL

Sincerely,

Charles
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top