473,756 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Merging joined data to MS Word

11 New Member
I'm looking to print off a booking form based on the data in 3 linked tables by merging it in Word. Please if you know of a better way, let me know.

Bookings table contains summary, cost, breakdown of cost, booking id, client id
Clients table contains clientid, name, address, phone
Sessions table contains date, time, activity, booking id

So one client books many sessions through one booking.

I can make a query that can be easily merged to Word containing the boooking and client information, but how can i include the many sessions that comprise one booking?

My attempts so far have produced a new doc for each session, ie. too many.

It seems Word won't link to more than one query at a time, but I can't make one query return all the info per line that word would require?

help?
May 2 '07 #1
7 1890
maxamis4
295 Recognized Expert Contributor
I am looking into your solution, i know it has been done, but never really had to do it my self. I have always been a fan of crystal reports or even the access reporting tool that comes with it. Have you tried creating a report in MS Access that looks like the word document? If it needs to be done in word, it is completely understandable.

let me know


I'm looking to print off a booking form based on the data in 3 linked tables by merging it in Word. Please if you know of a better way, let me know.

Bookings table contains summary, cost, breakdown of cost, booking id, client id
Clients table contains clientid, name, address, phone
Sessions table contains date, time, activity, booking id

So one client books many sessions through one booking.

I can make a query that can be easily merged to Word containing the boooking and client information, but how can i include the many sessions that comprise one booking?

My attempts so far have produced a new doc for each session, ie. too many.

It seems Word won't link to more than one query at a time, but I can't make one query return all the info per line that word would require?

help?
May 2 '07 #2
maxamis4
295 Recognized Expert Contributor
go there
[Link Removed]


I am looking into your solution, i know it has been done, but never really had to do it my self. I have always been a fan of crystal reports or even the access reporting tool that comes with it. Have you tried creating a report in MS Access that looks like the word document? If it needs to be done in word, it is completely understandable.

let me know
May 2 '07 #3
MMcCarthy
14,534 Recognized Expert Moderator MVP
Sorry Maximis4 linking to competing forums is frowned on.

ADMIN
May 4 '07 #4
phillyon
11 New Member
Sorry Maximis4 linking to competing forums is frowned on.

ADMIN
That's all very well but by redirecting me to a solution someone else has written rather than writing it out again he's just using good db protocol and normalising the whole affair.

So I missed the link you posted, any other ideas?
May 4 '07 #5
MMcCarthy
14,534 Recognized Expert Moderator MVP
That's all very well but by redirecting me to a solution someone else has written rather than writing it out again he's just using good db protocol and normalising the whole affair.

So I missed the link you posted, any other ideas?
Sorry I do understand. But I'm sure maximis4 will be able to help.
May 4 '07 #6
MMcCarthy
14,534 Recognized Expert Moderator MVP
maximis4 the rule on this is...

You can copy in the solution and give full credit to the original poster but you can't provide a link to the site, sorry.

Mary
May 4 '07 #7
maxamis4
295 Recognized Expert Contributor
I apologize for the link. You will have to do this in 4 steps


FIRST CREATE MODULE, NAME IT ANYTHING YOU WANT. COPY THE CODE BELOW INTO IT
Expand|Select|Wrap|Line Numbers
  1. Function CreateIt()
  2.  
  3.  
  4. Dim WordObj As Word.Application
  5. Dim db As Database
  6. Dim rs As New ADODB.Recordset
  7.  
  8. Set WordObj = CreateObject("Word.Application")
  9. Set db = CurrentDb()
  10. Dim ID, Criteria
  11.  
  12. With WordObj
  13. .Visible = True
  14. .Documents.Open ("C:\MyWord.doc") ' ** name and path for the document
  15.  
  16. rs.Open "Customers", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
  17. Criteria = "[CompanyName] = " & "'" & Forms!WordDemo!CompanyName & "'"
  18.  
  19. ID = DLookup("CustomerID", "Customers", Criteria)
  20.  
  21. rs.Find "[CustomerID]=" & "'" & ID & "'"
  22.  
  23. .ActiveDocument.Bookmarks("CoName").Select
  24. .Selection.TypeText rs.Fields("CompanyName")
  25.  
  26. .ActiveDocument.Bookmarks("Address").Select
  27. .Selection.TypeText rs.Fields("Address")
  28.  
  29. .ActiveDocument.Bookmarks("City").Select
  30. .Selection.TypeText rs.Fields("City")
  31.  
  32. .ActiveDocument.SaveAs "C:\NewDoc.doc"
  33. End With
  34.  
  35. rs.Close
  36. Set rs = Nothing
  37. Set WordObj = Nothing
  38. End Function
  39.  
Now before moving forward you need to understand that this works on the concept of bookmarks in word. Research those if you don't know how to use them. In your orginial document I recommend you create a template with bookmarks at ever insertion point where you want your document to have database data. For example like a mail merge create a bookmark called 'Last Name' which will create the document with a particular last name.

STEP 2 CREATE YOUR WORD TEMPLATE

STEP 3 CREATE A FORM WITH A BUTTON LIKE THE ONE LISTED BELOW
Expand|Select|Wrap|Line Numbers
  1. Private Sub MoveIt_Click()
  2. On Error GoTo Err_MoveIt_Click
  3.     Call CreateIt
  4.  
  5. Exit_MoveIt_Click:
  6.     Exit Sub
  7.  
  8. Err_MoveIt_Click:
  9.     MsgBox Err.Description
  10.     Resume Exit_MoveIt_Click
  11.  
  12. End Sub
  13.  
Now please under stand this will export any field you want. it all depends on queries that you write or the methods that you pass data.

STEP 4 MAKE SURE YOU HAVE THE MS WORD LIBRARIES PRESENT ON YOUR DATABASE.

you can finde the reference libraries under tools references in the code view. by default word should be in there, but i have seen times where it doesn't work.

I can email this example which I retrieved from Utter Access, but the rest of the development I leave in your hands.
May 4 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2070
by: Dan Nash | last post by:
Hi guys I wonder if you could help. I'm trying to create a bespoke interface for mail merging from an Access database in Word. At the moment, I'm just trying it with CSV files, and it works. Word loads, data gets pasted in and it merges fine. One problem tho, it's doing Form Letters rather than Mailing Labels Here's the code...
4
1479
by: rottyguy70 | last post by:
hello, am trying to do the following with little success. any help is appreciated. 1) assume i have a static mapping: a -> 1 b -> 2 c -> 3 2) i need to read through some data, let's say set and create
5
4042
by: Jerry Hull | last post by:
I'm working with a database developed by an untrained person over several years - and on a network that has recently been upgraded with a new server installed and MS office upgraded from 2K (I think - it might have been XP) to 2003. The database is impressive, both in what it does and the obtuse and inconsistent ways it works. There are several hundred queries, for example, with no indication of where they are used or if they are in fact...
1
4959
by: svdh | last post by:
I have posed a question last saturday and have advanced alot in the meantime. But I am still not there Problem is that I try to merging various fields from various tables in one document in Word 1. Query..I want to keep the fields seperatred. I do not want to sent on field with all accumulated languages from one person to Word. Each language should appear in the document in a separate cell Cross tables are not delivering the result I...
0
6298
by: mharris | last post by:
I need help with merging two Word documents into one through C# code. The problem isn't so much getting the documents put into one as it is maintaining the appropriate formatting, or rather reformating, after the merge. This is a full description of my needs. I have a C# class library that creates two Crystal Reports, and then exports them to the harddrive as Word documents. One's orientation is landscape, the other is portrait. I then...
1
4750
by: Paul H | last post by:
I have a very simple database containing one table called "tblProducts". The fields are: ProductID, Description, Price. I have a folder on my PC that contains image files. The image file names are based on the associated ProductID, i.e. 2001.jpg is a picture of ProductID 2001. I know how automate Word mailmerge using VBA in access, but I want to include the related pictures in the merged document. So the word doc will have a table in...
8
6725
by: babyangel43 | last post by:
Hello, I have a query set up in Access. I run it monthly, changing "date of test". I would like this query to be merged with a Word document so that the cover letter is created in Word, the fields from Access are automatically filled into the Word document. The query could be anywhere from 0-5000 names, one cover letter per name. AND to this cover letter for each applicant, there has to be attached a two page document. How in the world can...
0
1193
by: =?Utf-8?B?QmFkaXM=?= | last post by:
Hi, I'm trying to do mail merging in C#.NET and in one methods: Word.Application wrdApp; Word._Document wrdDoc; Object oMissing = System.Reflection.Missing.Value; Object oFalse = false; private void FillRow(Word._Document oDoc, int Row, string Text1,
7
4166
by: =?Utf-8?B?QmFkaXM=?= | last post by:
Hi, I'm trying to follow a mail merging example in C#.Net that I got from: http://support.microsoft.com/default.aspx/kb/301659 and in one the methods: Word.Application wrdApp; Word._Document wrdDoc; Object oMissing = System.Reflection.Missing.Value; Object oFalse = false;
0
9455
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10031
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9869
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9838
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9708
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8709
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7242
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5302
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3354
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.