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!

Formating Code Correctly

Status
Not open for further replies.

Eddie1976

Instructor
Oct 29, 2002
4
US
I have a value that is copied from one field to another. Below is the code I am using.

Me.NewInterestRate.Value =frmCreditorsBenefitsValues].Form![InterestRate].Value *100

The problem I am having is that the value is not always a number, it is occassionally a text field that I do not want to be multiplied by 100. I need help formating this code properly. Any help is appreciated.

Thanks.
 
us the IIf and isnumeric functions
would be something like this

iif Isnumeric(frmCreditorsBenefitsValues].Form![InterestRate].Value ),Me.NewInterestRate.Value =frmCreditorsBenefitsValues].Form![InterestRate].Value *100,
 
Close. It you left out a bit of the iif statement.

iif (Isnumeric(me!frmCreditorsBenefitsValues.Form!InterestRate),Me!NewInterestRate = me!frmCreditorsBenefitsValues.Form!InterestRate *100, me!frmCreditorsBenefitsValues.Form!InterestRate)

should do the trick.

But this is based on what is probably a faulty design. Your field should probably be allowed to hold either numeric values or text values, but not both.

Check out the "Fundamentals" article on my website for more.

Jeremy

==
Jeremy Wallace
AlphaBet City Dataworks
Affordable Development, Professionally Done

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
Jermey when I copied your statemtents into the on-click event of my button it highlights it in red and gives syntax error when you debug. Any ideas?

Thanks.
 
Put this in front of it.

Me!NewInterestRate =

If that doesn't work, check out the help files for the iif statement.

Jeremy

==
Jeremy Wallace
AlphaBet City Dataworks
Affordable Development, Professionally Done

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
Try this ...

Me!NewInterestRate = iif ( Isnumeric(me!frmCreditorsBenefitsValues.Form!InterestRate),me!frmCreditorsBenefitsValues.Form!InterestRate *100,
me!frmCreditorsBenefitsValues.Form!InterestRate)
 
Either be sure your textbox has been formatted as a number or use Val() to insure number. Remember the textbox is a text box. It tried to quess what you are doing but it is better to be rigerous.

rollie@bwsys.net

If the textbox = 1

textbox + textbox can either be 11 or 2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top