I am looking to export certain variables from ms access to ms word, Does
anyone have any idea how this is done. So far my function collects data from
two separate tables, and can open the word document that I need, but I am
unable to figure out how to make it write the collected data to the new word
document. Any help would be great.
Public Sub ShipmentRequest_Click()
Dim inv As Double
Dim getINV As String
Dim invNum As Double
Dim Exists As Boolean
Exists = False
inv = Me.Invoice
Me.OrderBy = "Invoice #"
Me.OrderByOn = True
DoCmd.GoToRecord acDataForm, "Sales Order Log", acLast
Do
getINV = InputBox("Enter Invoice Number", "Shipment Request", getINV)
Loop While (Not IsNumeric(getINV)) And getINV <> ""
If getINV <> "" Then invNum = getINV
Me.Invoice.SetFocus
DoCmd.FindRecord invNum, acEntire, , acSearchAll, True, acCurrent
If Me.Invoice = getINV Then
Exists = True
Else
MsgBox "Invoice Number Not Found"
End If
If Exists = True Then
Dim rst As Recordset
Set rst = CurrentDb.OpenRecordset("customerdbnew")
rst.MoveLast
Dim dbtotal As Integer
dbtotal = rst.Fields("ID") - 11
rst.MoveFirst
Dim CusNum As String
CusNum = 0
If Me.Customer__ <> "" Then
CusNum = Me.Customer__
End If
MsgBox CusNum
Dim i As Integer
i = 0
Dim PONum As String
PONum = 0
If Me.Customer_PO__ <> "" Then
PONum = Me.Customer_PO__
End If
MsgBox PONum
Do
If CusNum = rst.Fields("Customer Number") Then
Dim BillTo As String
BillTo = " "
If rst.Fields("Bill To") <> "" Then
BillTo = rst.Fields("Bill To")
End If
Dim ShipTo As String
ShipTo = " "
If rst.Fields("Ship To") <> "" Then
ShipTo = rst.Fields("Ship To")
End If
Dim VAT As String
VAT = " "
If rst.Fields("VAT #") <> "" Then
VAT = rst.Fields("VAT #")
End If
Exit Do
Else
rst.MoveNext
i = i + 1
End If
Loop While i < dbtotal
End If
MsgBox BillTo
MsgBox ShipTo
MsgBox VAT
Dim LWordDoc As String
Dim oApp As Object
'Path to the word document
LWordDoc = "\\Backup\misos bu\Released\SALE\Sale-4004_REV_9.doc"
'Create an instance of MS Word
Set oApp = CreateObject(Class:="Word.Application")
oApp.Visible = True
'Open the Document
oApp.Documents.Open filename:=LWordDoc
End Sub
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200508/1