|
-
January 3rd, 2006, 04:09 AM
#1
viewing and printing ms access reports
is there a way to view and print an ms access report?
whats the code? please help me!
-
January 3rd, 2006, 04:36 AM
#2
Re: viewing and printing ms access reports
 Originally Posted by matthewivan
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)
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
-
January 3rd, 2006, 07:52 AM
#3
Re: viewing and printing ms access reports
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?
Last edited by matthewivan; January 3rd, 2006 at 04:56 PM.
-
January 4th, 2006, 01:10 AM
#4
Re: viewing and printing ms access reports
 Originally Posted by matthewivan
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 statement
Code:
oAccess.OpenCurrentDatabase ("D:\db1.mdb")
If you have a password protected database then you would need to change the open statement
Code:
oAccess.OpenCurrentDatabase "D:\db1.mdb", , "password"
-
January 4th, 2006, 06:13 AM
#5
Re: viewing and printing ms access reports
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?
-
January 4th, 2006, 07:59 AM
#6
Re: viewing and printing ms access reports
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.
-
January 4th, 2006, 03:28 PM
#7
Re: viewing and printing ms access reports
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
-
January 5th, 2006, 01:17 AM
#8
Re: viewing and printing ms access reports
 Originally Posted by matthewivan
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.
Code:
oAccess.DoCmd.OpenReport ReportName:="myReport", View:=acViewPreview
-
January 5th, 2006, 07:26 AM
#9
Re: viewing and printing ms access reports
I'm so glad I stumbled across this thread. It answered a huge question for me But it gave me another.
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'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.
I am using an ADODB connection for everything else in my app.
Thanks a bunch
Buddy
-
January 5th, 2006, 07:46 AM
#10
Re: viewing and printing ms access reports
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.
-
January 5th, 2006, 10:25 AM
#11
Re: viewing and printing ms access reports
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 
Thanks a lot for your help Shuja
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|