Mail merge from form - with matching ID.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • HappyGlassify
    New Member
    • Dec 2009
    • 6

    Mail merge from form - with matching ID.

    Hope this is in the right place.

    I have an Access form which allows the user to look through appointments, each appointment having a specific ID.

    I would like to place a button on the form that will open a mail merge document in Word, with the Appointment ID corresponding to the ID of the current record when the button was clicked on the form. Make sense? I hope?

    Like, on the form, the details of Appointment 380 will be displayed, and when the user clicks the mail merge button, an invoice will open in Word with the required details of Appointment 380.

    I have already created the Word document based on an appointment query, but it lets me cycle through all the appointments, I need just one to be displayed. I just need to know how to link it to the form somehow.

    Thanks, hope this made sense.
  • nico5038
    Recognized Expert Specialist
    • Nov 2006
    • 3080

    #2
    Just change the query to filter for the value of the form or create an additional table with one row holding the ID and fill/update that value when selected in the form and JOIN your query to this table.
    Finally a public variable could be used too.

    Nic;o)

    Comment

    • HappyGlassify
      New Member
      • Dec 2009
      • 6

      #3
      I tried the first thing you said, putting [Forms]![AppointmentForm].[ID] as the query criteria, but I keep getting errors about the database being in a locked state by "Admin" whenever I try to open word. I think I'll just leave it, thanks anyway.

      Comment

      • nico5038
        Recognized Expert Specialist
        • Nov 2006
        • 3080

        #4
        Using the Table with one row option is easy to realize, just create a table (e.g. tblID) and add one row.
        Now place in the OnCurrent event of the form:
        Code:
        currentdb.execute ("UPDATE tblID SET ID=" & Me.Id)
        In the mail merge query add a JOIN of the ID with this table and try again.

        Nic;o)

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32656

          #5
          Originally posted by HappyGlassify
          I tried the first thing you said, putting [Forms]![AppointmentForm].[ID] as the query criteria, but I keep getting errors about the database being in a locked state by "Admin" whenever I try to open word. I think I'll just leave it, thanks anyway.
          I suspect this is due to your having the database open (and having some object in design mode - probably to look at the code) at the time. To test this you would need to run it without being in design mode at all.

          Comment

          Working...