|
-
Nov 6th, 2004, 08:46 AM
#1
Thread Starter
Fanatic Member
Access with word
I have a word document with bookmarks. I also have a database in access with a form. On the form is a button, when the user clicks on the button, i want to open the specific word document, transfer all the information from the text boxes to the relevant bookmarks and then print it off.
I do not know how to link the textboxes to the bookmarks and how to point to the word document. can someone help?
As for the printing auto i think its a macro created for as soon as the word document opens-am i right or will it print document before the transfer has happened?
-
Nov 7th, 2004, 11:52 AM
#2
Addicted Member
VB Code:
Function PrintDocument(Klant As Long, opdracht As Long)
Dim str As String
Dim doc As Object
Dim textdoc As Object
Dim wrdrange As Object
Dim adors As ADODB.Recordset
Dim naam As String
Dim vnaam As String
Set wd = CreateObject("Word.Application")
wd.Visible = False
Set doc = wd.Documents.Add("c:/program files/vbase/data/documents/dagboek.dot")
Set adors = New ADODB.Recordset
With adors
.Open "select naam, voornaam from klant where id=" & Klant, adocn, adOpenDynamic, adLockOptimistic
If Not .EOF And Not .BOF Then
doc.FormFields("Firstname").Range = " " & !voornaam
doc.FormFields("Lastname").Range = " " & !naam
End If
.Close
End With
Set adors = Nothing
this should help you on the way. BTW I'm using late binding as one can get into problems with different versions of word.
I used to do this a lot in Word and VB but now I rather use xl as the manipulation is easier.
greetz,
Jason
-
Nov 8th, 2004, 10:34 AM
#3
Thread Starter
Fanatic Member
See this doesn't make sense.
In your function, you've said klant as long-is this meant to mean the table?
See the thing is all the information i'm getting is from three linked tables.
A mixture of everything is loaded onto a form, and from then i want to copy them to the relevant bookmarks in word.
The code you showed only shows for one table. Thing is how do you say textbox1 = relevant bookmark?
My tables are as follows if this will assist you in helping me.
Invoice(Invoice no, date, company no, nett total, vat total, final total)
Description(Description No, description,net value, vat value, total, invoice no)
Sales Address(company no, company name,address)
On my form i have all of these only once.
Can you help me out please?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|