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

format? 1

Status
Not open for further replies.

reinaldo

Programmer
Mar 29, 2001
31
US
The following code which I have on a form works just fine. It draws information from a library and on Service Fee field I get the balance due for the previous invoice and on the description flied I get Balance on Invoice Number 05892. My problem come when I move to the next record and do the same thing, the service fee field puts the right dollar amount on the field, however the Description field now reads Balance on Invoice Number 5893 and omits the first digit which is the zero. I can only get this to work when the form first opens the all the other records have the first digit missing. Can someone tell me why this happens?

THANKS ALL

method pushButton(var eventInfo Event)
VAR
d Date
newd Date
invoiceNum Number
invoicetbl Table
lineitemtbl Table
endVar

dodefault

BalanceLib.Open("Balance")
outputArray["Invoice_No"] = Invoice_No.Value
outputArray["Balance"] = Balance.Value
BalanceLib.PassArray(outputArray)

If DraftDate=Blank()
then
msgStop("Financial Designs DBS, Inc.","Select a Draft Date for This Invoice")

else

if Balance.Value > 0.00
then

Invoice_No.Moveto()
Invoice.action(databeginedit)
Invoice.Action(DataEnd)
Invoice.Action(FieldDown)
Invoice_No.ReadOnly=False

invoicetbl.attach("Invoice.DB")
d = today()
newD = date(string(month(d)+1)+"/1/"+string(year(d)))
Invoice_Date.Value=Newd
invoicenum = invoicetbl.cmax("Invoice No")+1
Invoice_No.Value = invoiceNum
Action(FieldRight)
Invoice_No.ReadOnly=True

lineitemtbl.attach("lineitem.DB")
Debit_Date.Moveto()
lineitem.action(databeginedit)
lineitem.Action(DataEnd)
lineitem.Action(FieldDown)
Debit_Date.Value = Invoice_Date.Value
Action(FieldRight)

Amount_Paid.Value=0
Debit_Date.Value=Invoice_Date.Value
inputArray = BalanceLib.ReadArray()
Description.Value = "Balance on Invoice Number "+inputArray["Invoice_No"]
Service_Fee.Value = inputArray["Balance"]
Total_Invoice.Value=TotExt.Value
Service_Fee.Moveto()
BalanceLib.close()

else

BalanceLib.close()
Invoice_No.Moveto()
Invoice.action(databeginedit)
Invoice.Action(DataEnd)
Invoice.Action(FieldDown)
Invoice_No.ReadOnly=False

invoicetbl.attach("Invoice.DB")
d = today()
newD = date(string(month(d)+1)+"/1/"+string(year(d)))
Invoice_Date.Value=Newd
invoicenum = invoicetbl.cmax("Invoice No")+1
Invoice_No.Value = invoiceNum
Action(FieldRight)
Invoice_No.ReadOnly=True

Total_Invoice.Value=0
Amount_Paid.Value=0
Balance.Value=0
Endif

If Draft.Value="Yes"
then
DD.Value=DraftDate.Value
Else
DD.Value="N/A"
endif
endif
endmethod
 
Leading zeros are dropped from whole numeric values. I'm not certain how you are getting the first one to tell you the truth. If you must have a zero on a printed invoice (or something), draw a text box around the invoice field, then place the zero in front of it. Make sure the fonts are the same and you won't be able to tell the difference. 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
 
Mac,

You can also get leading zeros with a little less effort. Consider:

Code:
method run(var eventInfo Event)
var
   num  Number
endVar

   num = 3.14
   view( format( "w6.3,ez", num ) )

endMethod

Put another way: To get leading zeros, you need to convert the numeric value to a string using the format function. Be sure to create a string wide enough for the precision of the values you're working with.

Format can be used in calculated fields.

Hope this helps...

-- Lance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top