Formating in a CrossTab - dollars vs percent

I have a cross-tab in which I have added two additional calculated columns to show the difference between the two previous columns. 
One column shows the difference in dollars (since the previous columns are in dollars).
The second column shows the difference as a percent. My calculation works great for the Percent column, however the column is formatted as currency. This makes sense of course, since the data used for the calculation are also in dollars.
However, if I change the format of the percent column to be a percent, all of the other columns in my cross-tab also change to a percent. It seems that it is either an all or nothing situation.
I notice that when I select a field in the u201C% Changedu201D column, all of the values in the Cross-tab are selected. Is there a way to select only the column that I want to work with?
Can anyone point me in the right direction?
Thanks in advance.

Problem:  Cross Tab formatting different columns with dollars and percents within the same row
We would like to set certain columns to dollar values and certain columns to percent values in Cross tabs but you click on one row and it changes that value format for the whole row. We can only change either all dollars or all percents. What we would like is to be able to specify which columns are dollars and which ones are percents.
Solution:  Create a formula in the Format Field to pick a $ or % based on the current column.
1)  Right click on any data value and choose Format Field
2)  Click on the Number tab and click on the Customizeu2026 button
3)  Click on Currency Symbol tab, check Enable Currency Symbol,  choose Floating
4) Click the x-2 button for Position
Type in titles of the columns you want to have dollars values and let the rest go to percent
select GridRowColumnValue(<db field>)
case "<column title>", "<column title>", "<column title>" : crLeadingCurrencyOutsideNegative
default: crTrailingCurrencyOutsideNegative
(for example)
select GridRowColumnValue("merchant_transaction_detail_rpt.trans_date")
case "Current", "Previous", "Yr Ago" : crLeadingCurrencyOutsideNegative
default: crTrailingCurrencyOutsideNegative
5) Click the x-2 button for Currency Symbol
Type in titles of the columns you want to have dollars values and let the rest go to percent
select GridRowColumnValue(<db field>)
case "<column title>", "<column title>", "<column title>" : "$"
default: "%"
(for example)
select GridRowColumnValue("merchant_transaction_detail_rpt.trans_date")
case "Current", "Previous", "Yr Ago" : "$"
default: "%"
Hope this helps. This is copied and pasted from a word doc I created with screen shots that I can email to you if you think it will help.

Similar Messages

  • Error while processing conditional formatting formula in crosstab

    This conditional formatting formula must return one of the following Color Constants: ' A number, currency amount, boolean, date, time, date-time, or string is expected here. Details: errorKind
    The above error is displayed on the the Business Objects Report Server when running my report.
    The XI server version information is as follows:
    BusinessObjects Enterprise XI Release 2
    Business Objects
    11.5.0.3135
    20060628
    Crystal Reports XI Release 2
    Business Objects
    11.5.0.31327
    20060628
    My IDE is Crystal Reports 2008.
    The error is being generated for the following conditional formatting formula which is in my crosstab:
    evaluateafter ({@concatAppTypeAppMethod});
    if CurrentRowIndex = 1 then
        color(0,153,153)   
    else if CurrentRowIndex = 2 then
        color(168,146,101)
    else if CurrentRowIndex = 3  then
        color(0,51,153)
    else if CurrentRowIndex = 4  then
        color(204,51,51)
    else
        color(153,153,153)
    This formula is applied via the Crosstab "Format Field>Font" tab.  In the report developer (Crystal 2008) the report runs without error.  When deployed to the server it fails with the above error.
    Heres the details of {@concatAppTypeAppMethod}:
    whileprintingrecords;
    "Designs filed " + {Command.APPLICATION_METHOD}
    The crosstab is structured as:
    Row = {@concatAppTypeAppMethod}
    Column = {@getMonth}
    Summary = Count of {@concatAppTypeAppMethod}
    Details for  {@getMonth}:
    right(totext(year({Command.ACN_COMPLETED_DATE}),"#"),2) + totext(month({Command.ACN_COMPLETED_DATE}),"0#")
    The above functions Row i.e. {@concatAppTypeAppMethod} and {@getMonth} use fields from the SQL command. 
    {@getMonth} parses the ACN_COMPLETED_DATE field, obtains the record month and year and concatenates these as a string which can be displayed as follows in the crosstab:
    May-08, Jun-08 etc.
    {@concatAppTypeAppMethod} parses the APPLICATION_METHOD field and obtains the application filing method i.e. Online or Internally and concatenates the pretext "Designs filed " to the filing method (also a string).
    I have tried various combinations of whilereadingrecords, whileprintingrecords and evaluateafter() with no success.  The problem occurs because the conditional formatting formula is being executed before the records being formatted are ready. 
    I believe this is a problem with the crystal reports software and/or XI server. 
    Please prove me wrong.

    Hi Raghavendra,
    Thanks for your prompt answer!  Can you confirm?  Is it because I'm using calculated members in the report and these are not support by the XI server specified in my error report above?
    If so, do you have any suggestions with regard to how I might be able to create a graph with the following attributes:
    Show summary (count) of records per month per application method (i.e. online or internal. this is a database field retruned by the SQL command).  In addition I need to add a series to the graph that shows the totals number of records per month irrespective of the relative application method (i.e. sum of online and internal) and finally I need to show the total number of online applications (i.e. application method = online) as a percentage of the total number of applications for the month.

  • How to set a Conditional Format in a Crosstab

    Hello,
    I think I have a straight forward problem, but after reading the instructions I can't seem to make this work.
    I am using BI 10.1.3.4.1
    I have a crosstab that I have build as an RTF template that looks like the following
    name
    rolename, priv name, priv desc muser
    The report puts a 1, 2 or 3 value in muser. If it is a 1 or 2 I want the cell to be green if it is a 3 I want it to be Yellow
    Here is my conditional format that I am trying to make work for just the 1's
    <?if:MUSER=1?>
    <xsl:attribute
    xdofo:ctx="block" name="background-color">green</xsl:attribute>
    <?end if?>
    It doesnt seem to work. To make matters worse is NULLs out the value in Excel
    What am I doing wrong?

    Hi,
    I too use a cross tab with for-each@column/cell. For me the below code works. It colors the background.
    For NULL values do ensure that you print the MUSER value within the IF block.
    Thanks.

  • Crosstab formatting.

    I have cross tabs on several GF's that have a count{of field)and then a percent of the count{field}. The percent are listed in whole numbers with out in decimals - like 45% or 85% or 100%......The user would like them to be out to wo decimals - like 45.25% or 56.78% or 100.00%. When I go into the field and format it to two decimals it doesn't do it. It just doesn't accept the reformatting.....Is this something I am doing wrong or is this crystal? Does it not allow formatting % with in crosstab?

    Hi Todd,
        You need to write a formula in Format Field >> suppress of the percentage value.
    numbervar x:= CurrentFieldValue;
    false
    Write a formula in Format Field >> Display String to show decimals of the percentage value.
    numbervar x;
    Totext(x,2) & '%'
    Hope this helps,
    Regards,
    Vinay

  • Export Cross tab percent values to excel as percent format

    Post Author: mailtovenkats
    CA Forum: Exporting
    Hi,
       when im exporting percent values in cross tab report to excel then excel format cell is not converting as percent and its format as genreral. i want to be excel format as percent.
    Any one help me do to achive this.
    Thanks,
    Venki

    Dear Yuka,
    You may check this thread:
    Re: Incorrect date format in excel reports
    Thanks,
    Gordon

  • Can't show data labels in pie graphs as decimal number if the crosstab data

    I want to show my data labels in diagrams, as percent values, with three decimals.
    It occurs (in version Oracle Business Intelligence Discoverer Plus 10g (10.1.2.55.26)) it is only possible if the data format of the crosstab data also shows data with decimals. If the data are in integer format, the graphs data labels can only be shown in integer as well.
    Does anyone know how to fix the problem?
    In version Oracle Business Intelligence Discoverer Plus 10g (10.1.2.48.18) we can have a crosstab showing integers and a pie graph showing labels of pie slices where the labels are in percent with three decimals. It seems it does not work in the newer version Oracle Business Intelligence Discoverer Plus 10g (10.1.2.55.26)
    Thanks in advance

    It seems I have another similar problem in version Oracle Business Intelligence Discoverer Plus 10g (10.1.2.55.26):
    I have a Bar (Percent) graph based on a crosstab where the data is formatted as number with two decimals.
    The labels in the graph shows as number (0,76 instead of 76% and 0,13 instead of 13%). I want them to be shown in percent format.
    The Data Label format is set to “Number” with two decimals. I can change the Data Labels to Percent with two decimals and then it shows the data labels in the graph exactly as I want it. But after I have saved the workbook and then opened it again the changes has been “revoked” and is once again set to number with two decimals instead of percent.
    thanks (again) in advance

  • How to create the report in given format???

    Hi there,
    My table view gets the report in this format.
    Unit -----Report-----Sum
    u1----------A---------s1
    u1----------B---------s2
    u2----------A---------s3
    u2----------B---------s4
    U3----------A---------s5
    U3----------B---------s6
    I need report in the format:
    Unit------Report A------Report B-----Percent
    U1----------s1----------------s2-------------(s1/s2)*100 %
    U2----------s3----------------s4-------------(s3/s4)*100 %
    U3----------s5----------------s6-------------(s5/s6)*100 %
    I need conditional formating in percentage column where column cell turns green for > 98% and red for <= 98%.
    I used pivot table and used new calculated item to create percent column but I'm not able to do conditional formating there and append % sign.
    Is there any other method where I can create logical column in RPD side.
    Please advice

    hi,
    Here is the way to achieve the conditional formatting in pivot table i didn't tried out this :-)...
    http://itnewscast.com/middleware/obiee-pivot-conditional-format-grand-total-part-2
    thanks,
    saichand

  • Can't change JDev Customizer format by methods of BIBenas

    Hi all,
    I would like to ask you for help with customizing of format of crosstab column header – which I set in JDev crosstab creating.
    When I use JDev Customizer to setting format of catalogue crosstab column header (page Format of Customizer tool), I can’t change its color of background in application by ((ThinCrosstab)dataview).getColumnHeader().setViewStyle(vs).
    I thought that Customizer creates GridViewHeaderStyleManager bundles with FixedMargeableObject with ViewStyle defined by that format, but when I want to list all of bundles in the dataview (bundles of GridViewHeaderStyleManager, GridViewDatabodyStyleManager and GridViewFormatManager), there are not any.
    Can anybody help me, how can I change format of JDev Customizer by methods of BIBeans objects?
    Thanks
    Kamil Svoboda

    kuk

  • Formatted Data Losing its Value Upon Entering Crystal Reports

    Post Author: Horizon57
    CA Forum: General
    I am having an issue where I have tables of data in Access with the correct formatting (i.e. $, %, etc.) and when I create a table or graph in Crystal Reports, the formatting does not show up. Something that is 46.78% in Access, shows up in the following format (0.47) and dollar signs ($$) do not even show up. I am sure its not just a display issue with the data, because when I right click on a field in the field explorer and select the "Browse Data" option, the formatting is also missing in the same way that it is missing once that data is brought onto the report itself.
    Does anyone know why this is happening and how to fix this issue? I would like to avoid having to apply specific formatting to each field in each subreport using Crystal Reports (That could take hours!)
    Thanks

    I have sometimes also reproduced this behaviour without waiting these 3 minutes (more or less immediately).
    In addition, after reproducing this behaviour, the fileds becomes read only and you can not write any more data in it. ¿?

  • Formatted Search is driving me crazy - Customer Reference Number to UDF

    Hi all, what should of been a simple Formatted search has turning into a monstrosity.
    All I am trying to do is to copy my Customer Reference Number on a Sales Order Header, to a Header UDF, via Formatted Search. Here is my formatted search:
    SELECT $[$14.0.0] FROM ORDR T0
    That formatted search is connected to my UDF also at the sales order header level.
    Any ideas as to why this formatted search does not duplicate the customer reference number into my UDF?
    I am running 2007A SBO.
    Thanks guys.
    Mike
    Formatted search is: SELECT  Dollar[Dollar14.0.0]
    For some reason, this forum changes my SQL sentence into a URL.
    Let me try this again. SQL statement is SELECT DollarBracketDollar14.0.0Braket

    Hi Mike,
    Try this,
    ->> Create 1 UDF in Title(Header) Level on Sales Order(Marketing Documents).
    ->> UDF :
    Type - Alphanumeric.
    Length - 100. (because in SO Customer Reference Number Field Character is 100 in Table)
    Structure - Regular.
    ->> Assign the below FMS Query in UDF.
    ->> Autofresh of Customer/Vendor Ref. No..
    Ex.
    1. Goto the UDF and Clcik (ShiftAltF2).
    2. Select the SEARCH BY SAVED QUERY.
    3. Assign the FMS Query.
    4. Select the AUTO REFRESH WHEN FIELD CHENGES.
    5. Select Customer/Vendor Ref. No..
    6. Put the Tick Mark in Display Saved Values.
    SELECT $[ORDR.NumAtCard]
    or
    SELECT $[$14.0.0]
    Regards,
    Madhan.

  • The "apply" button didn't display when I was using the "write back" option

    I followed the "System Administrator's Guide" to configure the write back function, unfortunately,
    the "apply" button didn't display. Is there anyone can give some advice? Thanks!

    Just to check, did yiou restart the presentation services after placing the xml file?
    Is the template name in answers "SetKPIValue" consistent with the .xml file as you mentioned?
    Now, if you could try by putting a hard coded value in the update statement as well.
    Also, is the location where the .xml file is kept is,
    ORACLE_INSTANCE/bifoundation/OracleBIPresentationServicesComponent/coreapplication_obipsn/analyticsRes/customMessages
    P.S. Numeric columns must contain numbers only. They should not contain any data formatting characters such as dollar signs ($), pound signs or hash signs (#), percent signs (%), and so on. [Oracle Admin Guide]
    Edited by: 855532 on Jul 13, 2011 1:52 AM

  • Need help with calculating interest

    Hey im trying to find out where my calculations are screwing up on the interest is coming up wrong but i am unable to find out where. After every month its suppose to be deposit - withdrawl * monthly interest rate and then add that total to the new month etc... any help will be appreciated. Heres my class and test
    public class SavingsAccount
        private double bal;
        private double intRate;
    The constructor initializes an object with a
    balance and an annual interest rate.
    @param bal The account balance.
    @param intRate The annual interest rate.
        public SavingsAccount(double bal, double intRate)
        bal= 0.0;
        intRate = 0.0;
        The withdraw method withdraws an amount from
        the account.
        @param amount The amount to withdraw.
        public void withdraw(double amount)
            bal -= amount;
        The deposit method deposits an amount into
        the account.
        @param amount The amount to deposit.
        public void deposit(double amount)
            bal += amount;
        The addInterest method calculates the monthly
        interest and adds it to the account balance.
        public void addInterest()
        // Get the monthly interest rate.
        // Calculate the last amount of interest earned.
        // Add the interest to the balance.
         intRate = bal * (intRate/12);
         bal += intRate;
        The getBalance method returns the account balance.
        @return The account balance.
        public double getBalance()
        return bal;
        The getInterestRate method returns the annual
        interest rate.
        @return The annual interest rate.
        public double getInterestRate()
        return intRate;
        The getLastInterest method returns the last amount
        of interest earned.
        @return The last amount of interest earned.
        public double getLastInterest()
        return bal;
    import java.util.Scanner;
    import java.text.DecimalFormat;
    public class SavingsAccountTest
        public static void main(String args[])
        // Annual interest rate
           double intRate;
        // Starting balance
           double startBal;
        // Amount of deposits for a month
           double deposit;
           double totalDeposit;
        // Amount withdrawn in a month
           double withdrawn;
           double totalWithdrawn;
        // Interest earned
           double intEarned = 0;
        // Deposit accumulator
           deposit = 0.0;
           totalDeposit = 0.0;
        // Withdrawal accumulator
           withdrawn =0.0;
           totalWithdrawn = 0.0;
        // Months that have passed
           double months;
        // Create a Scanner object for keyboard input.
           Scanner keyboard = new Scanner(System.in);
        // Get the starting balance.
           System.out.println("What is your account's starting balance");
           startBal = keyboard.nextDouble();
           while (startBal < 0)
               startBal=0;
        // Get the annual interest rate.
           System.out.println("What is the annual interest rate?");
           intRate = keyboard.nextDouble();
           while (intRate <= 0 )
               intRate = 0;
        // Create a SavingsAccount object.
           SavingsAccount account = new SavingsAccount(0.0, 0.0);
        // Get the number of months that have passed.
           System.out.println("How many months have passed since the " +
                              "account has opened? ");
           months = keyboard.nextDouble();
           while (months <= 0)
               months = 1;
        // Get the deposits and withdrawals for each month.
        for (int i = 1; i <= months; i++)
        // Get the deposits.
           System.out.println("Enter the amount deposited during month " + i);
           deposit= keyboard.nextDouble();
           totalDeposit += deposit;
           while (deposit <=0)
               deposit = 0;
        // Get the withdrawals.
           System.out.println("Enter the amount withdrawn during month " + i);
           withdrawn = keyboard.nextDouble();
           totalWithdrawn += withdrawn;
           while (withdrawn <= 0)
               withdrawn = 0;
        // Add the deposits to the account.
           startBal += deposit;
        // Subtract the withdrawals.
           startBal -= withdrawn;
        // Add the monthly interest.
           intRate = startBal * intRate/12;
           startBal += intRate;
        // Accumulate the amount of interest earned.
           intRate += intEarned;
        // Create a DecimalFormat object for formatting output.
        DecimalFormat dollar = new DecimalFormat("#,##0.00");
        // Display the totals and the balance.
        System.out.println("Total deposited: " + dollar.format(totalDeposit));
        System.out.println("Total withdrawn: " + dollar.format(totalWithdrawn));
        System.out.println("Total interest earned: " + dollar.format(intEarned));
        System.out.println("Account balance: " + dollar.format(startBal));
    }

    Ok this is what i have fixed up so far but im still having trouble calculating the interest. Problem1) We were given the skeleton to the class and demo. I cannot figure out what to enter in getLastInterest.(completely lost all i need is hint) 2)When i try to get the Total money deposited and i call the account.deposit(balance) it keeps on giving an error void not allowed. Any help is appreciated
    public class SavingsAccount
        private double balance;
        private double interest;
        private double intEarned;
        The constructor initializes an object with a
        balance and an annual interest rate.
        @param bal The account balance.
        @param intRate The annual interest rate.
        public SavingsAccount(double bal, double intRate)
        balance = bal;
        interest = intRate;
        The withdraw method withdraws an amount from
        the account.
        @param amount The amount to withdraw.
        public void withdraw(double amount)
            balance -= amount;
        The deposit method deposits an amount into
        the account.
        @param amount The amount to deposit.
        public void deposit(double amount)
            balance += amount;
        The addInterest method calculates the monthly
        interest and adds it to the account balance.
        public void addInterest()
        // Get the monthly interest rate.
        // Calculate the last amount of interest earned.
        // Add the interest to the balance.
         interest = balance * (interest/12);
         interest = intEarned;
         balance += interest;
        The getBalance method returns the account balance.
        @return The account balance.
        public double getBalance()
        return balance;
        The getInterestRate method returns the annual
        interest rate.
        @return The annual interest rate.
        public double getInterestRate()
        return interest;
        The getLastInterest method returns the last amount
        of interest earned.
        @return The last amount of interest earned.
        public double getLastInterest()
        return intEarned;
    import java.util.Scanner;
    import java.text.DecimalFormat;
    public class SavingsAccountTest
        public static void main(String args[])
        // Annual interest rate
           double intRate;
        // Starting balance
           double balance;
        // Amount of deposits for a month
           double deposit;    
        // Amount withdrawn in a month
           double withdraw;
        // Interest earned
           double intEarned = 0;
        // Deposit accumulator
           deposit = 0.0;  
        // Withdrawal accumulator
           withdraw =0.0;    
        // Months that have passed
           double months;
        // Create a Scanner object for keyboard input.
           Scanner keyboard = new Scanner(System.in);
        // Get the starting balance.
           System.out.println("What is your account's starting balance");
           balance = keyboard.nextDouble();
           if (balance < 0)
               balance=0;
        // Get the annual interest rate.
           System.out.println("What is the annual interest rate?");
           intRate = keyboard.nextDouble();
           if (intRate <= 0 )
               intRate = 0;
        // Create a SavingsAccount object. Cannot find Symbol!!
           SavingsAccount account = new SavingsAccount(balance,intRate);
        // Get the number of months that have passed.
           System.out.println("How many months have passed since the " +
                              "account has opened? ");
           months = keyboard.nextDouble();
           if (months <= 0)
               months = 1;
        // Get the deposits and withdrawals for each month.
        for (int i = 1; i <= months; i++)
        // Get the deposits.
           System.out.println("Enter the amount deposited during month " + i);
           deposit= keyboard.nextDouble();
           account.deposit(deposit);
           if (deposit <=0)
               deposit = 0;
        // Get the withdrawals.
           System.out.println("Enter the amount withdrawn during month " + i);
           withdraw = keyboard.nextDouble();
           account.withdraw(withdraw);
           if (withdraw <= 0 || withdraw >= balance)
               withdraw = 0;
        // Add the deposits to the account.
           account.deposit(balance);
        // Subtract the withdrawals.
           account.withdraw(balance);
        // Add the monthly interest.
           account.addInterest();
        // Accumulate the amount of interest earned. ????? Wrong
           intRate += intEarned;
        // Create a DecimalFormat object for formatting output.
        DecimalFormat dollar = new DecimalFormat("#,##0.00");
        // Display the totals and the balance.
        System.out.println("Total deposited: " + dollar.format(account.deposit(balance)));
        System.out.println("Total withdrawn: " + dollar.format(account.withdraw(balance)));
        System.out.println("Total interest earned: " + dollar.format(account.addInterest()));
        System.out.println("Account balance: " + dollar.format(account.getBalance()));
    }

  • Custom Report: Actuals paid by Fiscal Year- multiple Columns

    Has anyone created a "time-scaled" InfoMaker report using "actuals paid"? We would like to create a report that shows actual payments made on each project broken down by fiscal year... so a single project may show actuals paid for FY 07-08, FY 08-09, and FY 09-10.. so "Actuals" would appear 3 times on the same report- based, on the approval date.
    I know that P6 can do this quite easily, but we are not linking CM to P6 schedule yet.

    Yes, I've created many reports of this nature including building a table that can be used to select a specific period for reporting on a given range. Have created these reports in several formats including tabular, crosstab, and graphical (and combinations of those).
    Rick

  • Can Validation Script Discern If a Field is Hidden?

    Hello All
    I use the validation script below to check for data in required fields on my form. I recently modified the form, changing three of the required fields from visible to hidden fields. The three fields are hidden unless the user makes a specific selection from a combo box. Then the three fields become visible, and if visible, should be required.
    I am stuck on how to tell the script to work as follows:
    1. If the three fields controlled by the combo box are visible, then they should be checked for the required data
    2. If the three fields controlled by the combo box are hidden, then the script should ignore checking them for the required data
    The three hidden/unhidden fields in the script are f5, f6, f7. Is there a way in the validation portion of the script to have it determine if the field is hidden or visible, and if visible check it for the required data?
    Thanks in advance for any ideas on this.
    var m = this.getField("txt_subject");
    var mysubject = m.value + " - Request Form Submission";
    var cType = "Reader";
    var cVersion = "< 7";
    var nWarning = 1;
    var cMsg1 = "This form cannot be submitted with your version of Acrobat Reader.";
    var cMsg2 = "You must use Acrobat Reader version 7 or higher.";
    // If Reader 6 or below is being used, display message telling user that "Email" and "Save Data" buttons don't work.
    if (app.viewerType == cType && app.viewerVersion == cVersion)
    app.alert(cMsg1 + cMsg2, nWarning)
    else {
              f1 = this.getField("txt_date");
              f2 = this.getField("txt_requested by")
              f3 = this.getField("txt_requested by phone");;
              f4 = this.getField("cbo_functional area");
      f5 = this.getField("cbo_dmm_ad_spon");
              f6 = this.getField("txt_buyer");
              f7 = this.getField("txt_buyer phone");
              f8 = this.getField("cbo_dmm_finan_spon");
      f9 = this.getField("tbx_coop_dmm");
              f10 = this.getField("tbx_load_dmm");
              f11 = this.getField("tbx_expected roi");
              f12 = this.getField("txt_event");
              f13 = this.getField("txt_start date");
              f14 = this.getField("cbo_am or pm");
              f15 = this.getField("txt_target audience");
                                if (f1.value == "")
                        {app.alert ('Please enter the date you are making this request".');
              if (typeof app.formsVersion != "undefined" && app.formsVersion >= 4.0)
              f1.setFocus();}
                        else if (f2.value == "Person making request")
                                  {app.alert ('The "Requested by" line cannot be blank. Please type the name of the person requesting this ad.');
                if (typeof app.formsVersion != "undefined" && app.formsVersion >= 4.0)
              f2.setFocus();}
                        else if (f3.value == "Phone #")
                                  {app.alert ('Please type the phone number of the person requesting this project.');
                if (typeof app.formsVersion != "undefined" && app.formsVersion >= 4.0)
              f3.setFocus();}
                              else if (f4.value == "Select a Functional Area")
                                  {app.alert ('Please select a Functional Area.');
              if (typeof app.formsVersion != "undefined" && app.formsVersion >= 4.0)
              f4.setFocus();}
                               else if (f5.value == "Select a DMM")
                                  {app.alert ('Please select a DMM.');
              if (typeof app.formsVersion != "undefined" && app.formsVersion >= 4.0)
              f5.setFocus();}
                                        else if (f6.value == "Buyer's name")
                                  {app.alert ('Please enter the name of the Buyer.');
              if (typeof app.formsVersion != "undefined" && app.formsVersion >= 4.0)
              f6.setFocus();}
                        else if (f7.value == "Phone #")
                                  {app.alert ('Please type the Buyer\'s phone number.');
                if (typeof app.formsVersion != "undefined" && app.formsVersion >= 4.0)
              f7.setFocus();}
              else if (f8.value == "Select a Financial Sponsor")
                                  {app.alert ('Please enter the financial sponsor.');
              if (typeof app.formsVersion != "undefined" && app.formsVersion >= 4.0)
              f8.setFocus();}
                    else if (f9.value == "Enter dollars or a % amount.")
                                  {app.alert ('Please enter a dollar or percent amount for coop.');
              if (typeof app.formsVersion != "undefined" && app.formsVersion >= 4.0)
              f9.setFocus();}
                   else if (f10.value == "Enter a dollar amount.")
                                  {app.alert ('Please enter an amount for load.');
              if (typeof app.formsVersion != "undefined" && app.formsVersion >= 4.0)
              f10.setFocus();}
                   else if (f11.value == "Enter a dollar amount.")
                                  {app.alert ('Please enter the expected ROI amount in dollars.');
              if (typeof app.formsVersion != "undefined" && app.formsVersion >= 4.0)
              f11.setFocus();}
                   else if (f12.value == "")
                                  {app.alert ('Please enter the Event name.');
              if (typeof app.formsVersion != "undefined" && app.formsVersion >= 4.0)
              f12.setFocus();}
                    else if (f13.value == "")
                                  {app.alert ('Please enter a start date for this email.');
              if (typeof app.formsVersion != "undefined" && app.formsVersion >= 4.0)
              f13.setFocus();}
                 else if (f14.value == "Select AM or PM")
                                  {app.alert ('Please select AM or PM for the Deployment time.');
              if (typeof app.formsVersion != "undefined" && app.formsVersion >= 4.0)
              f14.setFocus();}
                    else if (f15.value == "")
                                  {app.alert ('Please describe the target audience for this email.');
              if (typeof app.formsVersion != "undefined" && app.formsVersion >= 4.0)
              f15.setFocus();}
                 else
                                  // Email PDF.
                                  this.mailDoc(true, "[email protected]", "", "", mysubject);}

    I went through the form, and realized I am partially where I need to be: The required fields script checks the first of the three unhidden fileds, but then skips the other two.
    To recap, I have a combobox that, if the user makes a specific selection, that selection will make three hidden fields visible. When checking the fields on the form, the required fields script should then proceed as follows:
    1. If the three fields controlled by the combo box are visible, then they should be checked for the required data
    2. If the three fields controlled by the combo box are hidden, then the script should ignore checking them for the required data
    The three hidden  fields are:
    cbo_dmm_ad_spon
    txt_buyer
    txt_buyer phone
    When the three fields are visible the script checks the first one, cbo_dmm_ad_spon, but skips checking txt_buyer and txt_buyer phone, and instead goes on to the cbo_dmm_finan_spon field.
    I believe I've correclty implemented what AcroBishop recommended. Does anyone see where I may have gone wrong?
    var correctVersion = (typeof app.formsVersion != "undefined" && app.formsVersion >= 4.0);
    var m = this.getField("txt_subject");
    var mysubject = m.value + " - Email Request Form Submission";
    var cType = "Reader";
    var cVersion = "< 7";
    var nWarning = 1;
    var cMsg1 = "This form cannot be submitted with your version of Acrobat Reader.";
    var cMsg2 = "You must use Acrobat Reader version 7 or higher.";
    // If Reader 6 or below is being used, display message telling user that "Email" and "Save Data" buttons don't work.
    if (app.viewerType == cType && app.viewerVersion == cVersion)
    app.alert(cMsg1 + cMsg2, nWarning)
    else {
              f1 = this.getField("txt_date");
              f2 = this.getField("txt_requested by")
              f3 = this.getField("txt_requested by phone");;
              f4 = this.getField("cbo_functional area");
      f5 = this.getField("cbo_dmm_ad_spon");
              f6 = this.getField("txt_buyer");
              f7 = this.getField("txt_buyer phone");
              f8 = this.getField("cbo_dmm_finan_spon");
      f9 = this.getField("tbx_coop_dmm");
              f10 = this.getField("tbx_load_dmm");
              f11 = this.getField("tbx_expected roi");
              f12 = this.getField("txt_subject");
              f13 = this.getField("txt_objective");
              f14 = this.getField("txt_start date");
              f15 = this.getField("cbo_am or pm");
              f16 = this.getField("txt_target audience");
                                if (f1.value == "")
                        {app.alert ('Please enter the date you are making this request".');
               if(correctVersion) f1.setFocus();}
                        else if (f2.value == "Person making request")
                                  {app.alert ('The "Requested by" line cannot be blank. Please type the name of the person requesting this ad.');
               if(correctVersion) f2.setFocus();}
                        else if (f3.value == "Phone #")
                                  {app.alert ('Please type the phone number of the person requesting this project.');
               if(correctVersion) f3.setFocus();}
                              else if (f4.value == "Select a Functional Area")
                                  {app.alert ('Please select a Functional Area.');
               if(correctVersion) f4.setFocus();}
                    else if(f5.display == display.visible && f5.value == "Select a DMM") {
      app.alert ('Please select a DMM.');
               if(correctVersion) f5.setFocus();}
                         else if (f6.display == display.visible && f6.value == "Buyer's name")
                                  {app.alert ('Please enter the name of the Buyer.');
               if(correctVersion) f6.setFocus();}
                        else if (f7.display == display.visible && f7.value == "Phone #")
                                  {app.alert ('Please type the Buyer\'s phone number.');
               if(correctVersion) f7.setFocus();}
              else if (f8.value == "Select a Financial Sponsor")
                                  {app.alert ('Please enter the financial sponsor.');
               if(correctVersion) f8.setFocus();}
                    else if (f9.value == "Enter dollars or a % amount.")
                                  {app.alert ('Please enter a dollar or percent amount for coop.');
               if(correctVersion) f9.setFocus();}
                   else if (f10.value == "Enter a dollar amount.")
                                  {app.alert ('Please enter a dollar amount for load.');
               if(correctVersion) f10.setFocus();}
                   else if (f11.value == "Enter a dollar amount.")
                                  {app.alert ('Please enter the expected ROI amount in dollars.');
               if(correctVersion) f11.setFocus();}
                   else if (f12.value == "Launch? Expanded assortment? New sizes?")
                                  {app.alert ('Please enter the subject of this email.');
               if(correctVersion) f12.setFocus();}
                                     else if (f13.value == "Drive sales? Informational?")
                                  {app.alert ('Please enter the objective of this email.');
               if(correctVersion) f13.setFocus();}
                    else if (f14.value == "")
                                  {app.alert ('Please enter a start date for this email.');
               if(correctVersion) f14.setFocus();}
                 else if (f15.value == "Select AM or PM")
                                  {app.alert ('Please select AM or PM for the Deployment time.');
               if(correctVersion) f15.setFocus();}
                    else if (f16.value == "")
                                  {app.alert ('Please describe the target audience for this email.');
               if(correctVersion) f16.setFocus();}
                 else
                                  // Email PDF.
                                  this.mailDoc(true, "[email protected]", "", "", mysubject);}

  • Is it a bug in Sun's Tutorial example!!!!

    Hello everybody! I donno whether the following Tutorial example code is buggy or not but it won't run under j2sdk 1.4.2 and also under 1.5 as smoothly as Tutorial says(only the 1st line prints but not all). You can find the code:
    http://java.sun.com/docs/books/tutorial/essential/io/dataIO.html
    And the file name is:
    DataIODemo
    Does anyone know how to make it work?
    Thanks.
    --DM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    The author made a "bonehead" error - s/he hardcoded a newline character ('\n') when writing the invoice1.txt file. Since this is a UNIX/Linux character, it will not cause an error when run there - BUT - when run on an OS that doesn't use that convention - Windows, etc - it results in an incorrectly written file.
    This illustrates a code portability problem; don't hardcode!
    I leave as an exercise for the reader the correction of the format of the total dollar amount.
    A corrected copy is below. //********* preceeds changes. Compare with the original to see the differences.
    import java.io.*;
    public class DataIODemo
        public static void main(String[] args)
            throws IOException
            // write the data out
            DataOutputStream out  = new DataOutputStream(new
                FileOutputStream("invoice1.txt"));
            double[] prices       = {19.99, 9.99, 15.99, 3.99, 4.99};
            int[] units           = {12, 8, 13, 29, 50};
            String[] descs        = {"Java T-shirt",
                "Java Mug",
                "Duke Juggling Dolls",
                "Java Pin",
                "Java Key Chain"};
            char lineSep          = System.getProperty("line.separator").charAt(0);
            for (int i = 0; i < prices.length; i++)
                out.writeDouble(prices);
    out.writeChar('\t');
    out.writeInt(units[i]);
    out.writeChar('\t');
    out.writeChars(descs[i]);
    out.writeChar(lineSep);
    out.close();
    // read it in again
    DataInputStream in = new DataInputStream(new
    FileInputStream("invoice1.txt"));
    double price;
    int unit;
    StringBuffer desc;
    double total = 0.0;
    try
    while (true)
    price = in.readDouble();
    in.readChar();
    // throws out the tab
    unit = in.readInt();
    in.readChar();
    // throws out the tab
    char chr;
    desc = new StringBuffer(20);
    while ((chr = in.readChar()) != lineSep)
    desc.append(chr);
    System.out.println("You've ordered " +
    unit + " units of " +
    desc + " at $" + price);
    total = total + unit * price;
    } catch (EOFException e)
    System.out.println("For a TOTAL of: $" + total);
    in.close();

Maybe you are looking for