Subform to word

wannabepro

Registered User.
Local time
Today, 09:46
Joined
Jan 25, 2005
Messages
102
Okay, I searched prolly even hit my head over the keyboard several times to find something resourceful in context to what I am looking for. But I didn’t, if there is something out there and it didn’t appear during my search or I missed it by any chance. Then accept my apologies. Now here is the question.

I have a master form and a subform, now I am able to send my master form to word, and my subform is in the form of datasheet. And this datasheet has a combo box, so the user can select as my options as they want. I want these options to export to word with the master form. I tried doing that through doc variable and also as book mark, but the only thing that’s transferring is the first field. I know couple of ppl went through the same trouble to achieve the same goal as me. And they asked the same question but their queries were un-answered, is it something that can not be done??? I am sure there has to be a way to do this; I am looking for some assistance here. That I will really appreciate.

I know I have a topic going on for a while now, about the same topic. But seem like there is no point of bringing that thread up over again, and it’s kind of dead.
 
thanx so much again :). I am sorry, but would it be too much if I ask you for sample database, I will try to work with this, but if I have an example of how it has been done, that would be gr8.:)
 
ansentry said:
Here it is.



thank you very much, but how am I suppose to convert it to word, there isn't any script to do that or any button attached, should i try to use the above given vb scripting?

much appreciated :)
 
Here is the template that goes with the datbase, and word instructions.

Sorry I forgot to post it.

but how am I suppose to convert it to word, there isn't any script to do that or any button attached, should i try to use the above given vb scripting?

This is what I you could do;
(a) either create the merge using the instructions, template & sample database. This would then give you an idea how things work.

Or

(b) Change the code and try to do it directly into you database

Me I would go for option (a), then when you feel confident with the way the code works try it on you database.
 
Last edited:
thanx ansentry, I am still working on it. Its giving me so much trouble on this line, intCount = DCount("*", "tmakInvoiceDetails"),. I don't understand where the tmakInvoiceDetails is coming from. If you could shed some light on it. I know I am bugging you a lot :( sorry


thanx again
 
After a quick read, I would say that you have to create the queries for the merge.

Code:
   DoCmd.OpenQuery "qmakInvoice"
   DoCmd.OpenQuery "qmakInvoiceDetails

These would then make the required tables (tmakInvoiceDetails & tmakInvoice).
 
ansentry said:
After a quick read, I would say that you have to create the queries for the merge.

Code:
   DoCmd.OpenQuery "qmakInvoice"
   DoCmd.OpenQuery "qmakInvoiceDetails

These would then make the required tables (tmakInvoiceDetails & tmakInvoice).


I did that already, it gave me the error after that, I thought proly its the table name, but it seem like a field as well. Is it a field I have to add to table, kinda confusing :) I tried renaming the tables but it didn't work :(
 
You don't say what the error is your getting, very hard to help you if you don't expain what is happening.

I set up a db with the table and the code that checks for records in that table and it works fine.

Is this the code you are having trouble with?
Code:
'Check that there is at least one detail item before creating invoice
   intCount = DCount("*", "tmakInvoiceDetails")
   Debug.Print "Number of Detail items: " & intCount
   
   If intCount < 1 Then
      MsgBox "No detail items for invoice; canceling"
      Exit Sub
   End If
Did you declare this?

Code:
Dim intCount As Integer
 
Hi John,

I am attaching the error, and intcount has been declared as a variable, so there is no problem with that. I will search on this error, but if you think you know the meaning behind it, please do let me know.

Thanks again :)
 

Attachments

  • error.JPG
    error.JPG
    86.5 KB · Views: 164
tried looking for the error and found out either its corrupt or have to compact it, tried compacting it and then created another database, still no hope :( i feel like crying now.


One more thing I forgot to add, the first line of defining variables, where it says dm dbs As database, if I don't erase that line or single quote it, it gives me compiling error, 'user define type not defined'. And when I do make it a comment, it gets stuck on the other error that i mentioned in above post.
 
Last edited:
Have a look at the attached sample.

Off to bed it's 1:04AM
 
Last edited:
ansentry said:
Have a look at the attached sample.

Off to bed it's 1:04AM


Thanks, but after checking off all the required ref, I am getting a new error, Error No:3265 Item not found in this collection. I think either I am improving, as error is no longer same or I will be lost soon :(

Thanx and sweet dreams :)
 
Last edited:
objWord.ActiveDocument.Bookmarks("bmInformation").Select
objWord.Selection.Text = (CStr(Me!Form4.Form!txtinformation))

okay this is what i was using for the subform, I don't know if I am wrong, but I am getting only first selection that user made. Since its datasheet, it should give me as many as user wants. I don't know if I have to make changes on my template or if my code is wrong :( I am back to the original code, as the other code is driving me nuts by giving me so many errors. :( plz help me out, thanx
 
wannabepro,

I got the demo working if you want a copy let me know and I will post it here.

So that I am consistent .........it's 1.42AM and I am of to bed.
 
ansentry said:
wannabepro,

I got the demo working if you want a copy let me know and I will post it here.

So that I am consistent .........it's 1.42AM and I am of to bed.

that would be a gr8 help if you can post it. I would really be thankful to you :) Thanks ansentry for bearing me this long, I know I am a headache :)
 
Here it is.

Before you start to use it do the following;

1> Change this line of code to suit your system;

Code:
strTemplatePath = "C:\Documents and Settings\johna\Application Data\Microsoft\Templates\"

Make sure that the template Northwind Invoice.dot is in the above folder "Templates".

When you create your invoices, make sure that you minimize it and answer the question on your screen re saving.

I think that we can now close this thread.....................OK

Hope it all works out for you.
 
Last edited:
I appreciate all your help and bearing me for this long, thanks a lot.

I am afraid to ask for one more favor, I know that you will be able to help me out. I have done all the coding and stuff and its working fine, except for one thing. The subform, when it imports it takes all the selections even from the other records to the word. I tried everything. But, it still is doing the samething.
 
Have a look at:


Look at your query that makes the table for the details (subform) it should have something like this in it.

Code:
[Forms]![NameofMainForm]![PrimaryKey]

Have a look that the tables that are made by your make table queries,the PrimaryKey should all have the same number.
 

Users who are viewing this thread

Back
Top Bottom