is there a way to view and print an ms access report?
whats the code? please help me!
Printable View
is there a way to view and print an ms access report?
whats the code? please help me!
The easiest way would be to use the Access Object (Remember the machine should have MS Access installed on it)Quote:
Originally Posted by matthewivan
Code:Dim oAccess As Access.Application
Set oAccess = New Access.Application
oAccess.OpenCurrentDatabase ("D:\db1.mdb")
oAccess.Visible = True
oAccess.DoCmd.OpenReport ReportName:="myReport", View:=acViewNormal
where shall i put the code? i put the code in a command button then an error occur User type not defined? how to solve this problem?
where sohuld i put the code?
Are you using a Password Protected Database? And Does it give you an error on this statementQuote:
Originally Posted by matthewivan
If you have a password protected database then you would need to change the open statementCode:oAccess.OpenCurrentDatabase ("D:\db1.mdb")
Code:oAccess.OpenCurrentDatabase "D:\db1.mdb", , "password"
no im not using a password protected database the error occur in the Dim oAccess As Access.Application statement
--->User-defined type not defined
heres the whole code
Private Sub Command1_Click()
Dim oAccess As Access.Application ----> error occur here says that "User-defined type not defined"
Set oAccess = New Access.Application
oAccess.OpenCurrentDatabase ("D:\db1.mdb")
oAccess.Visible = True
oAccess.DoCmd.OpenReport ReportName:="myReport", View:=acViewNormal
End Sub
what does this mean?
Oh thats my Mistake. You need to add a reference to Microsoft Access 10 Object Library. Go to Project -->References and select Microsoft Access 10 Object Library. Then this code should work properly.
i've tried it but i'm using ms access 9.0 its okay now but when i tried it it directly print the report without previewing it. how to first preview it thank you very much
Just change the View option of the report to acViewPreview.Quote:
Originally Posted by matthewivan
Code:oAccess.DoCmd.OpenReport ReportName:="myReport", View:=acViewPreview
I'm so glad I stumbled across this thread. It answered a huge question for me :) But it gave me another.
I'm sure it's not possible, but I have to ask. Is there a way to bring up the report without opening Access at all.Code:Dim oAccess As Access.Application
Set oAccess = New Access.Application
oAccess.OpenCurrentDatabase ("D:\db1.mdb")
oAccess.Visible = True
'I added this to maximize the report within the Access window
oAccess.DoCmd.Maximize
'can you do something to maximize the window too? If not that's fine.
oAccess.DoCmd.OpenReport ReportName:="myReport", View:=acViewNormal
I am using an ADODB connection for everything else in my app.
Thanks a bunch:D
Buddy
Well I have never tried using Access Reports im my projects. So I actually never researched about this. But you could probably search on Google and if you are lucky you might get some nice samples.
Also try exploring ADOX. There might be some option of showing Access Reports there. Right now I don't have time, but if I find something I'll post it here.
Right now this is the only option I have.
I actually got everything to work how I wanted for the most part. I had to manually resize my Access window, but now everytime the report opens the window stays the same size. I'm satisfied with that.
I might try exploring ADOX, but this project has taken a great deal of exploring ADODB, I need a break.. lol :lol:
Thanks a lot for your help Shuja