Full Version: Inserting data from Access form to Word
UtterAccess Forums > Microsoft® Access > Access Forms
attachments
Is it possible to transfer certain fields from an Access form to a Word document? For example, I would like to be able to transfer the customer's name and the date, and also a serial number of a product into a word document that I am working on. Of course, it would need to be for the current record only. Is this possible? How would it be done?
attachments
Or even a new form that pops up and asks for the customer name, date, and serial number to be put into word. A little extra use for the user, but not out of the question.
attachments
Ok, nevermind. I guess it either can't be done or you all think it is too stupid of an idea to respond to.
will figure it out on my own and post back here when I do.
Thanks anyway
HiTechCoach
There are many post here on the subject.

You may also want to check out:

Sending the Current Record to Word 97 with Automation

and

Super Easy Word Merge.
You will have to scroll down the page to find it.

Hope this helps ...
attachments
Holy Access Batman (Coach)! You saved the day!
Thank you.
attachments
One last question I guess...I don't want to automatically print this as the code calls for, but when I delete that line, it gives me an error. How can I change it to make it stay open on the print preview but not print automatically? My code is as follows (this is just a sample that I am playing with so only have one field):
Private Sub MergeButton_Click()
On Error GoTo MergeButton_Err
Dim objWord As Word.Application
' Copy the Photo control on the Employees form.
' Remove the following comment in Microsoft Access 97.
' DoCmd.RunCommand acCmdCopy
' Remove the following comment in Microsoft Access 7.0.
' DoCmd.DoMenuItem acFormBar, acEditMenu, acCopy, , acMenuVer70
' Start Microsoft Word 97.
Set objWord = CreateObject("Word.Application")
With objWord
' Make the application visible.
.Visible = True
' Open the document.
.Documents.Open ("c:\NEWTESTPAGE.doc")
' Move to each bookmark and insert text from the form.
.ActiveDocument.Bookmarks("CUSTOMERNAME").Select
.Selection.Text = (CStr(Forms!customer!CustomerName))
End With
' Print the document in the foreground so Microsoft Word 97
' will not close until the document finishes printing.
objWord.ActiveDocument.PrintOut Background:=False
' Close the document without saving changes.
objWord.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
' Quit Microsoft Word 97 and release the object variable.
objWord.Quit
Set objWord = Nothing
Exit Sub
MergeButton_Err:
' If a field on the form is empty
' remove the bookmark text and continue.
If Err.Number = 94 Then
objWord.Selection.Text = ""
Resume Next
' If the Photo field is empty.
ElseIf Err.Number = 2046 Then
MsgBox "Please add a photo to this record and try again."
Else
MsgBox Err.Number & vbCr & Err.Description
End If
Exit Sub
End Sub
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.