Results 1 to 6 of 6
  1. #1
    Abacus1234 is offline Competent Performer
    Windows Vista Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    212

    Using MOD in an If statement in a Word Document pulling data from an access database.




    I'm using mod in an IF statement in a mergefield in a word document pulling data from an access database.

    I cannot copy the If statement into here, but if you can imagine parentheses, the following statement works for an interest rate, say 4.375, it returns 4

    I am using it successfully with an interest rate If =Mod Mergefield interestrate,1 =0" Mergefield Interestrate\#";;" " etc.

    I am trying to do something similar with a dollar field like 211,000.00, if I divide that by 1, I would get 211,000 . So in the IF Statement how would I express a remainder of nothing. I have tried IsNull, I have tried " ". I have tried .00.
    I just want to strip off the .00 from this currency field.

    Thanks for any suggestions.








  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    If you are doing the division in Word, you will have to format the field that is in Word. I imagine if you have it formatted as currency, you can adjust the decimal places via the field's properties window.

    If you are doing the division within Access, I would simply place the result into a long integer data type. This will truncate the number by dropping any fraction of a whole number (20.875 would become 20). If you need to do rounding, you can use the Round() function. I would review how this stuff works in Access to make sure you are getting your math correct.
    http://allenbrowne.com/round.html

  3. #3
    Abacus1234 is offline Competent Performer
    Windows Vista Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    212
    It's the Mod part of the If statement I am having problems with.

    The statement below works with InterestRate of 4.00

    {IF{=MOD({ MERGEFIELD InterestRate }, 1)= O"{MERGEFIELD InterestRate \#"0;;")" {MERGEFIELD InterestRate\#"0.00 } "}


    It formats the Interest Rate to be 4

    But I can't make it work on the Loanamount field which is formatted as currency.
    {IF{=MOD({ MERGEFIELD Loanamount }, 1)= 0"{MERGEFIELD Loanamount \#"$,0;;")" {MERGEFIELD Loanamount\#"$,0.00 } "}

    So I have taken the loanamount and multiplied by 100 so now I have cents and formatted it as a general number. I tried dividing the cents by 100 which should give me a remainder if there are cents. When I get no remainder, it should choose the second part of the If statement, and format it with no decimal places. But it always defaults to the second part of the If statement and gives me .00.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Try
    name\# $,0

  5. #5
    Abacus1234 is offline Competent Performer
    Windows Vista Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    212
    Thanks for the suggestions. I finally got it to work to the point where it would recognize a remainder of something, but not a remainder of 0. So I turned the If statement round to test on there being a remainder, and now it works. It's always worth the effort, when it finally works.

  6. #6
    Abacus1234 is offline Competent Performer
    Windows Vista Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    212
    Just to set the record straight, The solution I thought was working, was not. Eventually, I made the number field into a text field and then the MOD function worked. So I have reached a conclusion that the MOD function has some sort of problem, as it is surely meant to work on number fields. But thanks for your suggestions.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 8
    Last Post: 07-29-2014, 06:41 PM
  2. Replies: 3
    Last Post: 12-18-2013, 02:23 PM
  3. Create Database from Word Document
    By jwtasu in forum Import/Export Data
    Replies: 4
    Last Post: 06-15-2012, 02:12 AM
  4. transferring data from a Word document
    By bdaniel in forum Programming
    Replies: 5
    Last Post: 01-03-2012, 11:16 PM
  5. Replies: 5
    Last Post: 07-16-2010, 10:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums