Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MERGE ACCESS TO WORD 2

Status
Not open for further replies.

DIRENE

Technical User
Jan 19, 2004
51
US
I have see this Public Function CreateWordLetter a number of time and it seem to be really simple to use. But I can not get it to work maybe someone can help me I have the function name createWordletter I have a form with a command button it that on click I have:

Private Sub Command45_Click()
CreateWordLetter "C:\Documents and Settings\Irene\Desktop\dear"

End Sub

The problem is that when I click the button I get a compile error message: expected variable or procedure, not module.

Can someone tell me want I am doing wrong. Thank you Irene
 
Make it so

Sorry to bug you but regarding my previous post, one of my fields is a lookup to another table, I I seem to be inserting the ID (Primary field) into my word document instead of the appropriate value. My form has this field set to 0cm and so is not visisble when viewing on screen.

I assume that I need to do some knid of SQL query when outputting to word, sothing along the lines of SELECT appropraite value where the ID is the same as the Field value.

This is what I have done (Sorry this is such a basic question - I am not used to Access, but more used to PHP, MYSQL etc)



.ActiveDocument.Bookmarks("GeographicalArea").Select
If IsNull(Forms![Single Job View]![Geographical Area]) Then
.Selection.Text = ""
Else
'Table![Area]![
Dim TableLookup
TableLookup = "SELECT [Area] FROM [Area] WHERE ID == Forms![Single Job View]![Geographical Area]"
.Selection.Text = TableLookup
' .Selection.Text = (CStr(Forms![Single Job View]![Geographical Area]))
End If

Ideally I want the Value of the SQL query to be transefered to .Selection.Text.

hope this makes sense

:)



Caspar Kennerdale
 
Ok I made a new button and it works but I still have a question is there a way that my "bookmark name" can be change to letter case. In my database everything is caps
 
Irene:
.... yes, i think so. I'm not quite sure, but have a look in Access help, item "Format". There is a way to format a string all upper case or only first letter upper case...

Caspar:
I see from the == that you're used to PHP. ;-)
What the textbox looks like in the form is absolutely irrelevant. Plus: Your TableLookup statement compares the ID to your Area - won't work anyway.

So you either take the value from the form:
.Selection.Text=CStr(Forms![Single Job View]![Geographical Area])

or you use Access-internal Lookup function:
TableLookup=DLookup(field, domain, criteria)
in your case:
TableLookup=DLookup("Area", "Area", "ID=Forms![Single Job View]![ID]")

Hope this helps,
Andy

Andreas Galambos
EDP / Technical Support Specialist
(andreas.galambos@bowneglobal.de)
HP:
 
If you want to merge access data into a word letter, why don't you just go to word, open tools and mail merge. Click Create you document, letter, etc. Then Get Data, open data source. Change "Files of type" to MS Access. Find your database and select the table or query that contains your data. You will get an icon on your tool bar "Insert Merge Field". This is a drop down with a listing of all the fields available. Slip them into the proper place in your letter and you are done. Click the icon "merge into document" and you have your letters ready to print.

Everyone who posts in Tek Tips uses VBA lots. Unfortunately, I really don't speak VBA so have to find other ways to accomplish tasks. [2thumbsup]
 
What I really what to do is have a form with option goup on it 1month 2month ect. and a button that if option 1month is select that word opens with a letter named :eek:ne month make a letter from each person that match the query. Then if 2month is select word open with a letter named 2 month ect. Do you have any easy ansrews.

Thank you Irene
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top