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

Form or Library Format

Status
Not open for further replies.

reinaldo

Programmer
Mar 29, 2001
31
0
0
US
I created a library to pass 2 variables to a form. Var1 is an LongInt field and Var2 is a currency field. When I return the values to the form, I return the Var1 to an alpanumeric field called description. Var1 was originally formated to display 05532 but when it returns to the description field from the library, the number now displays as 5532. When I return Var2 it works just fine because I return the value to another like field (currency). Can I make the library return Var1 with the same formatting so that when I return it to the description field it will display with the leading zero?

THANKS ALL
 
If you are bringing it back as a string (alphanumeric), you have two choices. Convert it to a string before saving it to the library; or, simply add a "0" to the front of it. (myString = "0"+myString). Mac :)

"There are only 10 kinds of people in this world... those who understand binary and those who don't"

langley_mckelvy@cd4.co.harris.tx.us
 
reinaldo,

Mac's right in pointing out the difference between a string representation of a value and it's underlying datatype.

When you need a leading sero, you need to format the underlying value.

Personally, I prefer to separate the processing of the value in the library and its presentation on the final form and/or report.

You can do a few different things:

1. Change the Format property of the field object displaying the value on the form/report. (You can even create a custom format and use that consistently.)

2. Create a second library routine called getValue that retrieves and formats value from the library.

Use the format function to consistently provide leading zeroes.

Hope this helps...

-- Lance

 
Thanks for getting back to me. I managed to do a workaround to my problem. I created an undefined field in the form (newfield) and made the value, Var1, which is the longint return to that field. Then I formated the field so that it would have a leading zero using properites format. Finally I added code so that description value = newfield value.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top