tranhai_vn > 13-04-16, 06:04 PM
First check whether data is filled or not
If Nz(lsInvoice, "Null") = "Null" Then Exit Sub
' Access will try to pass selected data on a predefined word form by using this code snipset.
' Now initialize a Query builder so that Data corresponding to Listbox selection will be taken from database
' the query qry_paymentDetailLC contains all details of a valid request form for B/L endorsement... not do it.
Dim rs As New ADODB.Recordset
Dim SqlStr As String
SqlStr = "Select * from Query_DataKH where cc='" & cc & "';"
rs.Open SqlStr, CurrentProject.AccessConnection
If rs.EOF Then
MsgBox "There is no data for selected invoice..."
GoTo ExitSub
End If
' Now put data to word
'initialize word
Dim WordApp As Object
Dim WordDoc As Object
Set WordDoc = CreateWordDocument(WordApp)
' hide word away
WordApp.Visible = True
' open the file now
Set WordDoc = WordApp.Documents.Open(Forms![TraCuuDataKH].[txtpath])
' now prepare for replacing// remember the field name in word form
' these are example of using finding functions of word, such keywords must be unique
'[DATE_DAY]/[DATE_MONTH]/[DATE_YEAR]
'[LC_NUMBER]/[INVOICE_NUMBER]/[BILLED_CURRENTCY] [INVOICE_AMOUNT]/[COMMODITY]/[QUANTITY] [M_UNIT]
' For better and more systematic work, it is recommended that you should creat a table for
' cross-matching field name and word keyword.. but for this testing purpose - I just make this manually
' Field Name we will use for searching are:
'NoLC, Goods, tbl_LC.HoldAmount, NoInvoice, Quanlity, AmountUSD,
' Declaration of variable
Dim KeyWords As String, FieldName As String, i As Long
KeyWords = "[SOKHUNG]/[SOMAY]/[BIENSO]/[LOAIXE]/[NGAYBAN]/[TENKHACHHANG]/[DIACHI]/[DIENTHOAI]"
FieldName = "SoKhung/SoMay/BienSo/loaixe/NGAYBAN/TENKHACHHANG/DIACHI/DIENTHOAI"
'KeyWords = "[LC_NUMBER]/[INVOICE_NUMBER]/[BILLED_CURRENTCY]/[INVOICE_AMOUNT]/[COMMODITY]/[QUANTITY]/[M_UNIT]"
'FieldName = "NoLC/NoInvoice/USD/AmountUSD/Goods/Quanlity/Unknown"
tranhai_vn > 15-04-16, 04:17 PM