by Louis Molnar (1 Submission)
Category: Databases/Data Access/DAO/ADO
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sun 12th January 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Calls print-out options
API Declarations
Name of form name and source parameters needed
On Error GoTo ErrHandler
Dim strSQL As String
Dim strQryName As String
Dim strMsg As String
strQryName = "[form to be printed]"
strMsg = "Your query has been successfully printed."
strSQL = Nz(Me.txtSQL2.Value, "000") [will have to be adapted]
If strSQL <> "000" And strSQL <> "" Then
'If user enters a string, finish processing
'Open target file
DoCmd.OpenForm "[form to be printed]"
'Run print dialogue
DoCmd.RunCommand acCmdPrint
DoCmd.Close 'close file
Me.RecordSource = strSQL
Else
'No input, alert user & reset focus
strMsg = "Please make sure that all parameters are defined."
Me.txtSQL.Undo
End If
MsgBox strMsg
'Show confirmation message whether failed or successful
ExitHere:
Exit Sub
ErrHandler:
MsgBox Err.Description
Resume ExitHere
End Sub