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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export a query to excel

Status
Not open for further replies.

funkytunaa

Technical User
Oct 9, 2005
116
AU
I get how to export a query to excel...Not a problem.

What I don't get is how I can filter that query to a single record based on a ClientID that is selected in a form.

What I am ultimately trying to do is merge that information toa word document somehow. What I was going to do is export it to excel then merge it from there. If there is an easier way, please let me know.

Does this make sense?

Cheers!!!!!
 
Thanks for the advice, but I had a few issues trying to get it going, so I ditched the effort for a bit to get a fresh start because the mind was in melt down mode.

What I have done now is a bit of a work around and hopefully you'll be able to tell me if this is a good way or not.....Anyone...Bueller...

What I have is a database which is based on a [ClientID] I run a query through VB that takes the [ClientID] from a form and makes a new table with the [ClientID] number as the name of that table.

What I then have attempted to do is to open the word document and attach it to that table dynamically....doesn't work as I expected. Below is the VB code I have perhaps I may be in the wrong forum for this as it's more VB than anything else, but any direction at the moment would be good.

--------------Make the table using-------------

DoCmd.RunSQL "SELECT * INTO letter" & [Forms]![Menu Letters]![ClientID] & " FROM [letter query] WHERE [ClientID]=" & [Forms]![Menu Letters]![ClientID] & ";"

--------------Merge it--------------------------
Set wrd = CreateObject("Word.Application")
wrd.Visible = True
Set doc = wrd.Documents.Open("z:\document\letter.doc")
ActiveDocument.MailMerge.DataSource.TableName = letter" & [Forms]![Menu Letters]![ClientID]


-------------Nuke the Table---------------------

DoCmd.RunSQL "drop table letter" & [Forms]![Menu Letters]![ClientID]

----------------The End-------------------------


I think there may be a fairly high posibility I am doing this wrong but, I think it's fairly inventive really.

Cheers!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top