Re: printing access reports using vb.net
If you can not display Access at all then you can not use any of the code. this was in some of my first posts.
Since you need to show "a" report you need to use something else to display it like just a data grid, data environment report designer, or ???
Re: printing access reports using vb.net
I used a grid for my tables, I don't know what's best for reports.
Any idea's?
ps: sorry, thought it was clear everything had to happen inside the program.
Re: printing access reports using vb.net
You could print the report directly to a secondary form or use the print preview control dialog.
Re: printing access reports using vb.net
Which would be easiest to implement? Because I have to understand what I'm writing here, otherwise it's not very learnful.
Re: printing access reports using vb.net
Either one is about the same difficulty, not too easy but in .net
Re: printing access reports using vb.net
Ok, then either one is fine, choose which you can explain best to someone like me. I'm off to bed, have to get up at 3.45 tomorrow, night night.
Re: printing access reports using vb.net
NOOOOOEEEES my personal vb hero/guru left me!!
Re: printing access reports using vb.net
No, I have been out for a while but should be back now.
Try using the printpreview dialog control. There are some examples on the MS site for it. Try a search.
Re: printing access reports using vb.net
Re: printing access reports using vb.net
Ok, I tried looking, and I couldn't really find any examples which include access except for this one, I put my database in the samples map and replaced every northwind which wasn't in comment into the name of my database, and it doesn't work yet, I know I'll have to change some extra stuff, looking all of that up right now, but still, this code displays acces.
So maybe can you explain about the printpreview control dialog and other stuff?
And my teacher won't answer for the next 2 weeks, it's vacation now that's good :D and bad :( news..
Maybe if you add me on msn it's easier to explain than 40 posts, I know I'm not fast sometimes :o which doesn't make it easier.
Mine is [email protected] if it's ok by you, elseway we'll just use posts, slower but it'll work ;).
Re: printing access reports using vb.net
After 3 weeks still no answer, is this thread abbandoned? Right now I've got 4 days left, and I still don't know how to select the exact pages to print from the report. Right now it just prints all, and it's by code (yours). Can you explain me how to do this by the print preview control dialog?
This is the code I used from you btw, not that it matters anymore I think.
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim moApp As Access.Application
Dim acViewPreview As Access.AcView
Try
moApp = DirectCast(GetObject(, "Access.Application"), Access.Application)
Catch ex As Exception
If TypeName(moApp) = "Nothing" Then
moApp = DirectCast(CreateObject("Access.Application"), Access.Application)
Else
MessageBox.Show(ex.Message, "VB/Office Guruâ„¢ Access Demo", _
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
End Try
moApp.Visible = True
moApp.OpenCurrentDatabase("V:\Users\Frederik\Desktop\Bierdatabase met rapport.mdb")
moApp.RunCommand(Access.AcCommand.acCmdAppMaximize)
moApp.DoCmd.Maximize()
moApp.DoCmd.SetWarnings(False)
moApp.DoCmd.OpenReport("rptBierengoed", acViewPreview)
moApp.CloseCurrentDatabase()
End Sub
Re: printing access reports using vb.net
Ok, I'm editing this for resolved, I edited the code a bit more to add a printrange, and now it works like a charm. I'll still have to remove bits and pieces, but this is what I got for now.
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim moApp As Access.Application
Dim acViewPreview As Access.AcView
Dim begin As Integer
Dim einde As Integer
begin = CInt(TextBox1.Text) + 1
einde = CInt(TextBox2.Text) + 1
Try
moApp = DirectCast(GetObject(, "Access.Application"), Access.Application)
Catch ex As Exception
If TypeName(moApp) = "Nothing" Then
moApp = DirectCast(CreateObject("Access.Application"), Access.Application)
Else
MessageBox.Show(ex.Message, "VB/Office Guruâ„¢ Access Demo", _
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
End Try
moApp.Visible = True
moApp.OpenCurrentDatabase("V:\Users\Frederik\Desktop\Bierdatabase met rapport.mdb")
moApp.RunCommand(Access.AcCommand.acCmdAppMaximize)
moApp.DoCmd.Maximize()
moApp.DoCmd.SetWarnings(False)
moApp.DoCmd.OpenReport(ReportName:="rptBierengoed", _
View:=Access.AcView.acViewPreview)
' Print a report named Sales:
moApp.DoCmd.OpenReport(ReportName:="rptBierengoed", _
View:=Access.AcView.acViewNormal)
moApp.DoCmd.PrintOut(Access.AcPrintRange.acPages, begin, einde, Access.AcPrintQuality.acHigh, 1)
'moApp.DoCmd.OpenReport("rptBierengoed", Access.AcView.acViewPreview)
moApp.CloseCurrentDatabase()
End Sub
The +1 on beginning and ending is because the number 1 report is empty.