Private Sub cmdPrint_Click()
If Text1.Text = "" Then
MsgBox ("PO Number cannot be Blank..")
ElseIf Text2.Text = "" Then
PrintPO1
Else
If Text3.Text <> "" Then
PrintPO3
Else
PrintPO2
End If
End If
End Sub
Sub PrintPO1()
With CRT
.Connect = "dsn=192.168.0.2;uid=sa;pwd=sa123sa;dsq=iats"
.ReportFileName = App.Path & "\PO.rpt"
.DiscardSavedData = True
.SelectionFormula = "totext ({TRPOH.PONo}) ='" & Text1.Text & "'"
.RetrieveDataFiles
.SortFields(0) = "+{TRPOD.SortNumber}"
.Action = 1
End With
End Sub
Sub PrintPO2()
With CRT
.Connect = "dsn=192.168.0.2;uid=sa;pwd=sa123sa;dsq=iats"
.ReportFileName = App.Path & "\PO.rpt"
.DiscardSavedData = True
.SelectionFormula = "totext ({TRPOH.PONo}) >='" & Text1.Text & "' AND ({TRPOH.PONo}) <= '" & Text2.Text & "'"
.RetrieveDataFiles
.SortFields(0) = "+{TRPOD.SortNumber}"
.Action = 1
End With
End Sub
Sub PrintPO3()
With CRT
.Connect = "dsn=192.168.0.2;uid=sa;pwd=sa123sa;dsq=iats"
.ReportFileName = App.Path & "\PO.rpt"
.DiscardSavedData = True
.SelectionFormula = "totext ({TRPOH.PONo}) >='" & Text1.Text & "' AND ({TRPOH.PONo}) <= '" & Text2.Text & "'"
.SelectionFormula = "totext ({TRPOH.SuppCode}) ='" & Text3.Text & "'"
.RetrieveDataFiles
.SortFields(0) = "+{TRPOD.SortNumber}"
.Action = 1
End With