Jump to content

[problema] Imprimir relatório access pelo VB


jleites

Recommended Posts

Boas

Estou aqui com um problema, queria dar uma ordem para imprimir um determinado relatório do access usando o VB.

Uso o visual studio 2007 e já encontrei algumas coisas na net acerca do que quero fazer, mas quando transponho o código para o VB não reconhece as funções, por exemplo:

Option Explicit        
Private acc As Access.Application    

Private Sub Command1_Click()    
Dim view As Long    
Set acc = New Access.Application    
acc.OpenCurrentDatabase ("C:\TEST.mdb")    
acc.DoCmd.OpenReport "ReportName", acViewNormal 'acViewNormal means the report is just printed.    
acc.CloseCurrentDatabase    
Set acc = Nothing    
End Sub

mas ele da-me erro na linha 2, dizendo que o Access.Application não está definido.

ou então este:

Sub print_dialog()
On Error GoTo ErrorHandler
DoCmd.OpenReport "Report1", acViewPreview
'Opens print dialog for current screen (report in this case):
DoCmd.RunCommand acCmdPrint
ErrorHandler:
If Err.Number <> 0 And Err.Number <> 2501 Then
	MsgBox "Error: " & Err.Number & vbNewLine & Err.Description
	Exit Sub
End If
End Sub

mas também não reconhece o DoCmd

Cumps

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.