Private Sub Command202_Click()
Dim Filename As String
Dim Filename1 As String
Dim FilePath As String
DoCmd.SetWarnings False
Me.Refresh
Dim sql As String
sql = "SELECT [Forms]![ACC_ขายสินค้า]![text185] AS voucher_s_id INTO printbill;"
DoCmd.RunSQL sql
Filename = DLookup("voucher_s_id", "printbill") & " m"
FilePath = "d:\bills-suzu\RE\" & Filename & ".pdf"
DoCmd.OpenReport "ต้นฉบับใบเสร็จรับเงิน", acViewPreview, Filename
DoCmd.OutputTo acOutputReport, "ต้นฉบับใบเสร็จรับเงิน", acFormatPDF, FilePath
DoCmd.PrintOut , , , , 1
sql = "SELECT [Forms]![ACC_ขายสินค้า]![text185] AS voucher_s_id INTO printbill;"
DoCmd.RunSQL sql
Filename1 = DLookup("voucher_s_id", "printbill") & " c"
FilePath = "d:\bills-suzu\RE\" & Filename1 & ".pdf"
DoCmd.OutputTo acOutputReport, "สำเนาใบเสร็จรับเงิน", acFormatPDF, FilePath
DoCmd.PrintOut , , , , 2
Command202_DblClick_Exit:
Exit Sub
Command202_DblClick_Err:
MsgBox Error$
Resume Command202_DblClick_Exit
End Sub