Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 340
  • Last Modified:

is it possible to change field types from within a script

i have a layout defining a payment plan:
the amount field is defined as numeric and displayed as numeric with the $ sign
however, for the last month i would like to replace the amount with asterics as in this example

1st month  $100.00 numeric field
2nd month $100.00 numeric field
3rd month $100.00 numeric field
4th month ****** change to text field

my question is: using a script, is there a way to change the fieldtype for the one field (4th month) on the layout to go from numberic to text so the asterics will show on final printing and then back to numeric after it prints.

if i have asterics in the numeric fields now they dont print.
thanks
0
kauakea
Asked:
kauakea
  • 10
  • 9
  • 2
1 Solution
 
billmercerCommented:
You can't change the actual definition of the numeric field itself, but you can use a simple calculation to change how the value is displayed when the layout is printed.

The Get(WindowMode) function will return a 0 if the window is in browse mode, a 1 if it is in find mode, a 2 if it's in preview mode, or a 3 if it is actually in the process of printing.

Assuming you have a field called Month4, define an unstored calculated field called Month4Asterisks, and define it to have this value:

  If( Get (WindowMode) > 1; "******"; Month4 )

Use this field on your layout in place of the Month4 field. Now, whenever you're printing or previewing the layout, the asterisks will appear. But when browsing, it will display the number instead.

You can accomplish the same thing with scripting, but it will be more effort, and will only work when the user prints with that script. A calculated field will work even if the user bypasses the printing script.

You can add additional formatting to the calculation to fine-tune how it will display in each mode, if you like.
0
 
lesouefCommented:
... and add something to detect the current month is the last one using max(month)
should look like:
[month field for layout] = If( Get (WindowMode) > 1 and Month=max(month) ; "******"; month )
0
 
kauakeaAuthor Commented:
i run all reports through scripts. there is a main menu and they click on a button and the report prints. there is no other option other than print when it comes to the report layout. i disable all options through a custom menu for printing.

lesouef, that looks like what i need to do because the final month is always going to change depending on how many payments there are.
so i would actually setup 12 fields [month1 field for layout, month2 field for layout, etc] for each month since there is a maximum of 12 payments possible. i would substitute the Month for the actual month of the payment
"[month1 field for layout] = If( Get (WindowMode) = 3 and Month1=month1 maxflag = "Yes" ; "******"; month1"
where i can set a maxflag field with "yes" for the final months payment field when creating the payment plan after the script exits the loop which is used to create each months payment date and payment amount.
i would have 24 new fields: 12 [month field for layout] and 12 [maxflag field]
would this be correct????

0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
lesouefCommented:
not really, this is far too complex.
i don't know yr base, but why do you need 12 month fields?
yr report should be a summary per month, and therefore, there should only be 1 month field for data and another one for the printed layout, based on the foreseen calculation. the max(month) works assuming all dates are in the same month field.
seems that somewhere you data structure is not suited for yr need...
0
 
kauakeaAuthor Commented:
basically i have a payment plan of 12 months.
we want to have it put in a report in 3 columns of 4 payments:
date1 pay1  date5 pay5  date9 pay9
date2 pay2  date6 pay6  date10 pay10
date3 pay3  date7 pay7  date11 pay11
date4 pay4  date8 pay8  date12 pay12
and we want to put ***** in the last payment to reference a footnote in the report.

i have one table that has 25 fields, the first field is the main number that i use for the relationship and then 12 date fields and 12 amount fields that i set via the script when i create the payment plan. there is one record per main number.
0
 
lesouefCommented:
so what? you could still use 12 payments records using only 2 fields each, and use a layout on 4 columns like you do for labels printing for instance.
instead you created 1 record with 24 fields, but to create a special field for printing *********, you'll need another 12 fields... not smart.
nevertheless, you could also change the field to be hidden on the fly before and after printing if you wanna keep yr existing stuff if you're happy with it.
- scan though all 12 fields to locate the last one, comparing with the current date month
- store its related value in a variable
- replaces its value with *********
- print
- restore the value from th variable
0
 
kauakeaAuthor Commented:
that is what i did originally but with a numeric field set with "*****" the asterics dont print on the report.
the payment plan is set in the middle of page of the report:

company header first and then verbage
After due review, the association has agreed to accept the payment plan set forth below. To initiate this payment plan, you must sign and return this agreement along with your first payment.

date1 pay1  date5 pay5  date9 pay9
date2 pay2  date6 pay6  date10 pay10
date3 pay3  date7 pay7  date11 pay11
date4 pay4  date8 pay8  date12 pay12

thank you

kauakea, collections agent
0
 
lesouefCommented:
"*****" the asterics dont print on the report
---------
can't you make it text? all you need is to format it yrself for the amount of decimals, and the currency symbol
that is only one expression to calculate, and better than creating 12 extra fields
0
 
kauakeaAuthor Commented:
i am going to make the field text. i was just hoping there was a way to keep my numeric fields numberic and my text fields text
0
 
lesouefCommented:
btw, **** should print in a num text
0
 
kauakeaAuthor Commented:
what is a num text??
0
 
lesouefCommented:
numeric! sorry, I am a lazy...
and you should have read:
btw, **** should print even in a numeric field
0
 
kauakeaAuthor Commented:
for some reason it does not work. i set the field with "*****" and if i am on the layout and click on the field it shows the "*****" but it does not show in browse or preview mode or when i print the report.
0
 
lesouefCommented:
you probably miss a point, it does work here.
try reducing the amount of stars maybe?
I insist it does work...
0
 
kauakeaAuthor Commented:
actually you are right. i needed to change the numer format of the field from "format as decimal" to 'general format' and it works. but then i dont get the $ sign or the thousands separator
0
 
lesouefCommented:
just that? put the $ as static text in the layout next to the field
0
 
kauakeaAuthor Commented:
but then if the field has "****" it displays as $****. is there a way to suppress the $ for the field that has the '****'???
0
 
lesouefCommented:
you'd need to calculate it! too much...
you could also put the $ in the numeric field when you populate it together with the value, and skip it when you insert ******
It does not even prevent further calculations, if you use getasnumber(field) on it if necessary.
are we finished for tonight?! getting late here, almost 3am...
0
 
kauakeaAuthor Commented:
we are done.  thanks i appreciate the suggestions. i will play with it a bit more.
0
 
lesouefCommented:
glad you were...
I did an example to check, and it works.
0
 
billmercerCommented:
kauakea, you should try to put as much information in your original question as possible, the question you ended up getting answered was very different than what you originally asked.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 10
  • 9
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now