Hi,
I'm trying to print an access report through visual basic, but I have
2 report that I made in access. the first one is to print all the
report and the other one, the user must enter the name of the
department to print the report of that department.
I don't understand preety much access, so I would like to know if
there are any way that vb could print the report without open the
access.
Here's the code:
Private Sub Label7_Click()
On Error Resume Next
strReportName = "relatorio_escolha"
'Assigns an object reference to a variable or property.
Set appAccess = New Access.Application
With appAccess
'Abrir a base de dados
.OpenCurrentDatabase constrDBName
.Visible = True
'Abrir o relatrio para Preview
'.DoCmd.OpenReport strReportName, acViewPreview --> already comment
this code to prevent previewing in access.
'Imprimir o relatrio
.DoCmd.OpenReport strReportName, acViewNormal --> before print, the
access is open and a inputbox is open in access where the user must
enter the name of the department. I want if is possible, instead of
opening access to prompt the inputbox, can the inputbox prompt in
visual basic?
Because the users can't access to the database
End With
Set appAccess = Nothing
' erros
If Err.Number = 3011 Then
MsgBox ("Form with 'Old' name cannot be found, maybe it has already
been renamed.")
appAccess.Quit
Set appAccess = Nothing
Exit Sub
ElseIf Err.Number = 7866 Then
MsgBox (strDBpath & " has been opened exclusively by another
user.")
appAccess.Quit
Set appAccess = Nothing
Exit Sub
End If
End Sub
Thanks!
Pucca