Page 1 of 3 123 LastLast
Results 1 to 15 of 38
  1. #1
    Star Lounger
    Join Date
    Jun 2008
    Location
    Baltimore, Maryland, USA
    Posts
    90
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Add/ Multiply Expression Inside AND Expression (2003 / 2007)

    Good afternoon.

    I have yet another field code expression that has defeated me. I am pretty sure that it is just a matter of rearranging or removing some characters. I have tested numerous variations, with no success.

    I need to insert two-part expression into a larger AND expression. In its first part, this new expression adds two variables, and tests for the sum being less than or equal to the product of a multiplication expression in the second part. (That make it clear, doesn't it?)

    It is simpler than it sounds. I think I just need some help with parentheses placement, something like that. Please see the attached document. It contains a pared down example.

    Thank you.

    Kevin
    Attached Files Attached Files

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Add/ Multiply Expression Inside AND Expression (2003 / 2007)

    Your expressions are becoming so complicated that sooner or later it will become impossible to understand or modify them in Word.
    I recommend performing the necessary calculations in the data source, or if that isn't possible, in the query used by Word to get the data. That should be a lot easier to create and modify.

  3. #3
    Star Lounger
    Join Date
    Jun 2008
    Location
    Baltimore, Maryland, USA
    Posts
    90
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Add/ Multiply Expression Inside AND Expression (2003 / 2007)

    Hans -

    The expressions are used in customized Word documents that are printed through the main (loan) software program. You create the documents through the loan program, which interfaces with Word, and opens the Wprd program when the user creates or modifues a document. From that view, all of the tools in Word are available.

    To test the expressions on the document, I go back to a screen in the loan software, enter data in the fields that corespond to the document expressions, and then Print Preview the document to test the expressions. Is that what you mean by testing in the data source?

    Kevin

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Add/ Multiply Expression Inside AND Expression (2003 / 2007)

    No, i meant to create the expressions either in the source software. For example, one can create formulas in an Excel worksheet and calculated columns in an Access query. I have no idea whether your loan software has a comparable ability.

    Microsoft Word uses an SQL statement to get the data for the mailmerge. You can modify this SQL statement through VBA to add the calculated expressions that you want to use in your mailmerge; these calculated expressions become additional merge fields that you can use directly. This was the other option I mentioned.

  5. #5
    Star Lounger
    Join Date
    Jun 2008
    Location
    Baltimore, Maryland, USA
    Posts
    90
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Add/ Multiply Expression Inside AND Expression (2003 / 2007)

    I see. The source softwarte has no platform within itself to facilitate expression creation. It interfaces with Word so that the user can create their own documents that populate with data from the fields in the source software. But it caannot do this independently.

    Is the Word query VBA option a way to enable the expresssions to function on the document independent of the source program (so that somepne could test them right on the document )?

    Kevin

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Add/ Multiply Expression Inside AND Expression (2003 / 2007)

    Yes, you can manipulate the SQL for any mail merge. To see the SQL, do the following:
    - Open a mail merge document (i.e. a document in which the data source for a mail merge has been specified).
    - Activate the Visual Basic Editor (Alt+F11).
    - Activate the Immediate window (Ctrl+G).
    - Type <code>? ActiveDocument.MailMerge.DataSource.QueryString</code> and press Enter.
    - You should see something like

    SELECT * FROM `Loans`

  7. #7
    Star Lounger
    Join Date
    Jun 2008
    Location
    Baltimore, Maryland, USA
    Posts
    90
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Add/ Multiply Expression Inside AND Expression (2003 / 2007)

    Hans -
    I created an Excel document that contains substitute fields (to take the place of the fields in the loan program). I then replaced the loan program field codes in the Word document expressions with the Excel field codes.

    I went through the VBA steps, but I keep getting a "Compile Error: Expected Case box. The name it searches for is Sheet1$,which I believe is correct. I tried removing the dollar sign from the name, in case that character was not recognized, but still got the error box. Us this error related to the name of the source document?


    Kevin

  8. #8
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Add/ Multiply Expression Inside AND Expression (2003 / 2007)

    Hans has probably retired for the night. Can you post the offending line of code and a few lines before and following?
    Regards
    Don

  9. #9
    Star Lounger
    Join Date
    Jun 2008
    Location
    Baltimore, Maryland, USA
    Posts
    90
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Add/ Multiply Expression Inside AND Expression (2003 / 2007)

    Hi, Don.

    The code is on the arrachment with the first message in the post, with brief explanatory notes.

    Kevin

  10. #10
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Add/ Multiply Expression Inside AND Expression (2003 / 2007)

    Attachment?
    Regards
    Don

  11. #11
    Star Lounger
    Join Date
    Jun 2008
    Location
    Baltimore, Maryland, USA
    Posts
    90
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Add/ Multiply Expression Inside AND Expression (2003 / 2007)

    Here it is. Thank you.

    Kevin
    Attached Files Attached Files

  12. #12
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Add/ Multiply Expression Inside AND Expression (2003 / 2007)

    In the previous post I meant the VBA code which threw the compile error.
    Regards
    Don

  13. #13
    Star Lounger
    Join Date
    Jun 2008
    Location
    Baltimore, Maryland, USA
    Posts
    90
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Add/ Multiply Expression Inside AND Expression (2003 / 2007)

    My apologies.

    This is the text in the Immediate Window -

    ? ActiveDocument.MailMerge.DataSource.QueryString
    SELECT * FROM `Sheet1$`

    After pressing the Enter key, I get the "Compile Error: Expected Case box.

    Kevin

  14. #14
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Add/ Multiply Expression Inside AND Expression (2003 / 2007)

    Sorry Kevin

    That's out of my league.
    Regards
    Don

  15. #15
    Star Lounger
    Join Date
    Jun 2008
    Location
    Baltimore, Maryland, USA
    Posts
    90
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Add/ Multiply Expression Inside AND Expression (2003 / 2007)

    That's OK. Thank you for looking at it.

    Kevin

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •