How do I create a single form letter for individual data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • emandel
    New Member
    • Dec 2006
    • 65

    How do I create a single form letter for individual data

    OK I am an amateur and your patience is appreciated.

    I have a database of Donors with their donations. I want to create a button (macro <?>)on my donation form that will automatically open a document in MS Word that will thank the donor for that specific donation. So this is something that I will do as the donation comes in. one donation in, one letter sent. The key is that I don't want a new query (e.g. query all donations in the past week) I want to do it in real time, but have the mail merge document ready to go, and just press the button. Does that make sense?

    Thank you
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32636

    #2
    I'm not very good with Word to be fair, but I think MailMerge requires the selection of the data to be controlled from Word itself. It's a Pull of data rather than a Push from the source if you like. I expect you could use Application Automation to get Word to do what it needs. As I say, I cannot help much there.

    Comment

    • hansnext
      New Member
      • Jul 2010
      • 6

      #3
      A way to do this would be to create a report based on a query which uses the ID of the current record in its WHERE clause and with the boiler-plate text of your form letter as a label on the report. Include the donor's details (name etc.) in the query and then you will be able to place it on the report. The button on your form would run the report to acPreview and then you can just use the Export to Word function from the tool-bar to get it into Word. You can do more elaborate things with application automation but if you are doing this record by record you probably don't need that much.

      Comment

      • emandel
        New Member
        • Dec 2006
        • 65

        #4
        Originally posted by hansnext
        A way to do this would be to create a report based on a query which uses the ID of the current record in its WHERE clause and with the boiler-plate text of your form letter as a label on the report. Include the donor's details (name etc.) in the query and then you will be able to place it on the report. The button on your form would run the report to acPreview and then you can just use the Export to Word function from the tool-bar to get it into Word. You can do more elaborate things with application automation but if you are doing this record by record you probably don't need that much.
        "which uses the ID of the current record in its WHERE clause" can you explain this sentence? I am not understanding it.

        Thanks.

        Comment

        • emandel
          New Member
          • Dec 2006
          • 65

          #5
          Originally posted by emandel
          "which uses the ID of the current record in its WHERE clause" can you explain this sentence? I am not understanding it.

          Thanks.
          sorry for bumping back up, but I am still very unclear as to how to do this.

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32636

            #6
            Originally posted by emandel
            emandel: "which uses the ID of the current record in its WHERE clause" can you explain this sentence? I am not understanding it.
            I expect this is referring to opening the report with a filter (WhereCondition parameter of the DoCmd.OpenRepor t call).

            For some examples on how to build up a filter string see Example Filtering on a Form.

            Comment

            • hansnext
              New Member
              • Jul 2010
              • 6

              #7
              "which uses the ID of the current record in its WHERE clause" can you explain this sentence? I am not understanding it.
              Apologies if I was obscure - NeoPa's post is what I meant. You just write the query with the fields you want in the letter, then the report with the boilerplate text and the fields (such as client name & address)from the query. Then on the form where the users sees the individual record you put a button with code LIKE this behind its OnClick event:
              Code:
              Private Sub buttonPrintIndividual_Click()
              On Error GoTo Err_buttonPrintIndividual_Click
                  Dim strReportName As String
                  Dim whereClause As String
                  strReportName = "rptStandardIndividualLetter" 
              'Get the ID of the current record from the form  
                  whereClause = me.RecordID.value
              'Check that there is a current record
                  If whereClause  <> "" Then
                  DoCmd.OpenReport strReportName, acViewPreview, , whereClause 
              Else
              MsgBox "There is no current record"
              Docmd.cancelevent
              End if
              Exit_buttonPrintIndividual_Click:
                  Exit Sub
              Err_buttonPrintIndividual_Click:
                  MsgBox Err.Description
                  Resume Exit_buttonPrintIndividual_Click   
              End Sub
              I say LIKE this because I have not tested this code although I have used similar. In effect the query and report you write will return all of the records, but when you pass the WhereClause on the OpenReport event it filters the recordset for the report down to just that record that matches the ID of the record that is current in the form. I hope that is clearer?
              One other point - I have found that you cannot guarantee that when an Access Report is exported to Word that the formatting in Word exactly matches what you would see if you printed the report directly from Access. In my experience it is a waste of time to put any effort into layout, graphics or lines in a report as they get lost or wrecked in the export to Word. Simpler is better. Of course you could just print the letter from Access assuming you are sending snail-mail.

              Comment

              Working...