Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Help with Lookup on Fed Tax Table

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Help with Lookup on Fed Tax Table

    This is a little project to track my time and verify that my hours and taxes are right on my paycheck.

    I've been trying to do a Lookup on the Fed_Tax_Table file. The filter uses the Pay Year, Filing Status and Pay Frequency, Low End Wage and High End Wages. I'm not having any luck. I thought it was the way I was using quotations in the filter so I've tried 3 different ways (see the buttons on the lower right of the form "My Pay Check").

    I have been using Excel to do this for several years and thought it would be a good Alpha5 project. My next step would be to add the State Tax Table and calculate the YTD totals. I know, why store the YTD's when they can be calculated... Small number of records, only me on the system, something different to try.

    If anyone can help with the lookup problem, I would appreciate it. I've attached a zipped copy of the DB.

    Thanks in advance,
    Jerry Gray

    #2
    Re: Help with Lookup on Fed Tax Table

    Jerry,
    At home currently and only have v5 available but I think you are having trouble constructing the lookups.

    First thing to remember is

    everything inside two quotation marks is taken literally.

    Code:
    avar = "King"
    ? "I am avar"
    = "I am avar" (Not "I am King")
    Your first button has a line of code

    Code:
    Add_Base = lookup("fed_tax_table","fed_tax_table->Tax_Year=[COLOR="Red"]My_Pay_Period->Pay_Year[/COLOR] .and. fed_tax_table->Filing_Status=My_Pay_Period->Fed_File_Stat .and. fed_tax_table->Pay_Frequency=My_Pay_Period->Pay_Frequency) .and. fed_tax_table->Wage_Bottom>=My_Pay_Period->Taxable_Fed_Ms .and. fed_tax_table->Wage_Top<=My_Pay_Period->Taxable_Fed_Ms","Base_Tax")
    This is interpreted by Alpha without regard as to your intention to substitute the values represented by such things as My_Pay_Period->Pay_Year. Inside the quotes My_Pay_Period->Pay_Year is interpreted literally as "My_Pay_Period->Pay_Year". IOW Alpha doesn't know you want it to put something in the place of the text My_Pay_Period->Pay_Year.

    Then you have to tell Alpha how to handle the things you do substitute. Numeric values are not an issue because Alpha does that for you. Character values must be quoted.

    You first line thus should look like....

    Code:
    Add_Base = lookup("fed_tax_table","fed_tax_table->Tax_Year="+My_Pay_Period->Pay_Year+" .and. fed_tax_table->Filing_Status="+quote(My_Pay_Period->Fed_File_Stat)+" .and. fed_tax_table->Pay_Frequency="+quote(My_Pay_Period->Pay_Frequency)+" .and. fed_tax_table->Wage_Bottom>="+My_Pay_Period->Taxable_Fed_Ms+" .and. fed_tax_table->Wage_Top<="+My_Pay_Period->Taxable_Fed_Ms,"Base_Tax")
    You can experiment in the interactive editor with statements such as these to get the feel for them. Write down some likely values for

    My_Pay_Period->Pay_Year
    My_Pay_Period->Fed_File_Stat
    My_Pay_Period->Pay_Frequency
    My_Pay_Period->Taxable_Fed_Ms

    then try something like this in the interactive (filling in reasonable values for the fields you want to substitute)

    Code:
    Add_Base = lookup("fed_tax_table","fed_tax_table->Tax_Year="+2008+" .and. fed_tax_table->Filing_Status="+quote("M")+" .and. fed_tax_table->Pay_Frequency="+quote("W")+" .and. fed_tax_table->Wage_Bottom>="+3+" .and. fed_tax_table->Wage_Top<="+3,"Base_Tax")
    ? Add_Base
    =?????(I don't know)
    There can be only one.

    Comment


      #3
      Re: Help with Lookup on Fed Tax Table

      Jerry

      See the attached zip file -

      First I think from looking at the fed tax table and comparing it to your lookup field filter, you might have a calculation wrong

      Code:
      .and. fed_tax_table->Wage_Bottom[color="red"]>=[/color]My_Pay_Period->Taxable_Fed_Ms .and. fed_tax_table->Wage_Top[color="red"]<=[/color]My_Pay_Period->Taxable_Fed_Ms
      might it be

      Code:
      .and. fed_tax_table->Wage_Bottom[color="blue"]<=[/color]My_Pay_Period->Taxable_Fed_Ms .and. fed_tax_table->Wage_Top[color="blue"]>=[/color]My_Pay_Period->Taxable_Fed_Ms
      The first way according to following the lookup table filter - will never have the bottom and the top on the same record - the second one will.

      Also as Stan pointed out first you were using single quotes and then you used the quote() function.

      In the zip file it seems like the filter works if you change the quotes to double quotes and swap the less than and the greater than.

      No knowing the fed tax code in detail I may be all wet on that but anyway try the zip file to see if the proper tax is written to the field this way using the new calculation swapping the less than and greater than

      FWIW

      Tom Baker

      Comment


        #4
        Re: Help with Lookup on Fed Tax Table

        Stan, I tried so many different ways, it looks like I screwed it up some.

        Tom, I plugged your code into my app and it works great. You were correct in the >= and <= mistake. In making the different examples, I was copying parts and pasting.

        I quite often work so long on something that none of it makes sense.

        Thank you for your help...now on to the other bells and whistles.

        Thanks again,
        Jerry Gray

        Comment


          #5
          Re: Help with Lookup on Fed Tax Table

          Jerry

          I forgot to say last night that I also changed the calculation of the "NEW_TAX" as follows

          Code:
          New_Tax = Add_Base + ((My_Pay_Period->Taxable_Fed_Ms - Over_Amt)*Add_Pct/100)
          I added "/100" after Add_Pct to make it a decimal. The amount in the fed tax table for the percentage are full numbers not decimal.

          I am sure you found this out already, but just wanted to let you know what else I changed.

          Tom

          Comment


            #6
            Re: Help with Lookup on Fed Tax Table

            Tom,

            Thanks again.

            I have moved the code to a script to be run from the OnChange event for the Current_Total_Income and Current_Total_Deductions fields both have field rules so any changes will automatically update the taxes.

            I have done some work on the MS tax table. The exemption amounts vary for the different filing status's. There is no calculation involved, so I plan to use a case statement for the lookup to pull the amount based on the exemption amount.

            Jerry Gray

            Comment


              #7
              Re: Help with Lookup on Fed Tax Table

              I have a problem with Lookup() syntax too. I can create the simple Lookup() syntax but complex .... I need your help.

              I made several tables, an employee, Employee_taxfile, Payroll_head, Payroll_days, and Fedeeral_Tax tables for simple Payroll system.
              the Payroll_days table has employee_id and payroll date fields with parent table as Employee.

              I am trying to get a field value from Federal_tax table and calculate it.
              I am on Payroll_days table. I used the Code Editor, Function Interactive page.
              My pseudocode is
              (1) Payroll_days->Emp_id = current record (?) Emp_taxfile->emp_id
              (2) Look up the Emp_taxfile->emp_file_status value
              (3) Look up the Emp_taxfile->emp_Pay_period value
              (4) Look up the Emp_taxfile->emp_County value
              (5) Payroll_head->Period_from_date = Federal_tax->Start_date
              (6) Federal_tax->File_status = Emp_taxfile->emp_file_status
              (7) Federal_tax->File_period = Emp_taxfile->emp_pay_period
              (8) bring a field value ("allowance)

              dim vFdrallow as n

              vFdrallow=lookup("tax_fdr",\
              "tax_year=payroll_head->tax_year .and. txfdr_filing_status = payroll_days->emp_file_status .and. tax_fdr->file_period = payroll_days->emp_file_period" ,\
              "Txfdr_allowance")

              ?vFdrallow
              = 0
              I know I wrote wrong on above syntax. Obviously, That all I can think about it. I could not figured out ..

              I will make a Zip files by Tomorrow and send it.

              Comment


                #8
                Re: Help with Lookup on Fed Tax Table

                Code:
                vFdrallow=lookup("tax_fdr",\
                "tax_year=payroll_head->tax_year .and. [COLOR="Red"]txfdr_[/COLOR]filing_status = payroll_days->emp_file_status .and. tax_fdr->file_period = payroll_days->emp_file_period" ,\
                "Txfdr_allowance")
                This part looks wrong. Maybe

                Code:
                vFdrallow=lookup("tax_fdr",\
                "tax_year=payroll_head->tax_year .and. [COLOR="Red"]tax_fdr->[/COLOR]filing_status = payroll_days->emp_file_status .and. tax_fdr->file_period = payroll_days->emp_file_period" ,\
                "Txfdr_allowance")
                If so it can be reduced to

                Code:
                vFdrallow=lookup("tax_fdr",\
                "tax_year=payroll_head->tax_year .and. filing_status = payroll_days->emp_file_status .and. file_period = payroll_days->emp_file_period" ,\
                "Txfdr_allowance")
                You are looking up into tax_fdr, you don't need to specify that table in the filter.
                There can be only one.

                Comment


                  #9
                  Re: Help with Lookup on Fed Tax Table

                  Good Morning, Stan

                  Thank you for your tip.
                  "You are looking up into tax_fdr, you don't need to specify that table in the filter"

                  I try it now.

                  Comment


                    #10
                    Re: Help with Lookup on Fed Tax Table

                    Hi Stan,
                    I looked UP and DOWN, Left and Right, Above and below, Top and bottom, Add and Minus but still not find the way to get out here.

                    My Interactive code Editor:

                    t=table.open("tax_fdr")
                    ? t.records_get()
                    = 2

                    t.fetch_first()
                    ? t.ALLOWANCE
                    = 60
                    ? t.START_DATE
                    = {01/01/2008}

                    ? t.FILE_STATUS
                    = "Single "


                    t.fetch_last()
                    ?t.ALLOWANCE
                    = 67.31
                    ?t.TAX_YEAR
                    = "2008"

                    ?t.FILE_STATUS
                    = "Married "

                    t2=table.open("payroll_head")
                    ?t2.PAYROLL_YEAR
                    = "2008"
                    t3=table.open("employees")
                    ?t3.TAXFILE_STATUS
                    = "Married "
                    ?t3.TAXFILE_FREQUENCY
                    = "Weekly "

                    vEmpStatus ="married"
                    ?vempstatus
                    = "married"

                    vFdrAll=lookup("tax_fdr","file_status="+quote("vEmpStatus"),"Allowance")
                    ?vfdrall
                    = 0 <--- WRONG, Why?

                    vFdrAll = lookup("tax_fdr","tax_year = payroll_head->payroll_year .and. file_status = employees->taxfile_status .and. file_period =employees->taxfile_frequency","allowance")
                    error: lookup(tax_fdr,tax_year = payroll_head->payroll_year .and. file_status = employees->taxfile_status .and. file_period =employees->taxfile_frequency,ALLOWANCE) Field is not recognized
                    ERROR: Extra characters at end of expression <== Error Message


                    'My Syntax Breakdown
                    'vFdrAll = lookup("tax_fdr",
                    '"tax_year = payroll_head->payroll_year
                    '**Tax_year ==> I used convertion, cyear(Start_date, field name)
                    '**Payroll_year ==> I used convertion, cyear(payroll_start_date, field name)
                    '.and. file_status = employees->taxfile_status
                    '.and. file_period =employees->taxfile_frequency", "allowance")


                    'Tom Baker Sample
                    'Add_Pct = lookup("fed_tax_table",
                    '"Tax_Year=My_Pay_Period->Pay_Year
                    '.and. Filing_Status=My_Pay_Period->Fed_File_Stat
                    '.and. Pay_Frequency=My_Pay_Period->Pay_Frequency
                    '.and. Wage_Bottom<=My_Pay_Period->Taxable_Fed_Ms
                    '.and. Wage_Top>=My_Pay_Period->Taxable_Fed_Ms","Add_Tax")

                    vFdrAll = lookup("tax_fdr","tax_year = "+payroll_head->payroll_year+" .and. file_status = "+quote(employees->taxfile_status)+" .and. file_period ="+quote(employees->taxfile_frequency),"allowance")
                    error: lookup(tax_fdr,tax_year = 2008 .and. file_status = "Married " .and. file_period ="Weekly ",ALLOWANCE)
                    Argument is incorrect data type <== Error Message


                    ' Stan Sample
                    'Add_Base = lookup("fed_tax_table","fed_tax_table->Tax_Year="+My_Pay_Period->Pay_Year+"
                    '.and. fed_tax_table->Filing_Status="+quote(My_Pay_Period->Fed_File_Stat)+"
                    '.and. fed_tax_table->Pay_Frequency="+quote(My_Pay_Period->Pay_Frequency)+"
                    '.and. fed_tax_table->Wage_Bottom>="+My_Pay_Period->Taxable_Fed_Ms+"
                    '.and. fed_tax_table->Wage_Top<="+My_Pay_Period->Taxable_Fed_Ms, "Base_Tax")

                    How can I fix it and understand the lookup() syntax?

                    Comment


                      #11
                      Re: Help with Lookup on Fed Tax Table

                      OOP. I Added too much " on, +Quote(name), here.
                      vEmpStatus ="married"
                      ? vempstatus
                      = "married"


                      vFdrAll=lookup("tax_fdr","tax_fdr->file_status="+quote(vEmpStatus),"allowance")
                      ?vfdrall
                      = 67.31
                      Simple Lookup is fine.

                      Comment


                        #12
                        Re: Help with Lookup on Fed Tax Table

                        John,

                        Can you zip your files and post them?

                        Jerry Gray

                        Comment

                        Working...
                        X