Page 2 of 2 FirstFirst 12
Results 41 to 72 of 72

Thread: [RESOLVED]printing access reports using vb.net, you be da man robdog

  1. #41
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: printing access reports using vb.net

    There should be a print to and print from argument of the .Print method. Or how are you invoking the print as of now?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  2. #42

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    115

    Re: printing access reports using vb.net

    invoking the print?

  3. #43

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    115

    Re: printing access reports using vb.net

    this is all my code, maybe that tells you what you need:
    Code:
    Option Explicit On 
    Option Strict On
    Imports Microsoft.Office.Interop
    
    
    Public Class Form1
        Inherits System.Windows.Forms.Form
    
    
    
    #Region " Windows Form Designer generated code "
    
        Public Sub New()
            MyBase.New()
    
            'This call is required by the Windows Form Designer.
            InitializeComponent()
    
            'Add any initialization after the InitializeComponent() call
    
        End Sub
    
        'Form overrides dispose to clean up the component list.
        Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
            If disposing Then
                If Not (components Is Nothing) Then
                    components.Dispose()
                End If
            End If
            MyBase.Dispose(disposing)
        End Sub
    
        'Required by the Windows Form Designer
        Private components As System.ComponentModel.IContainer
    
        'NOTE: The following procedure is required by the Windows Form Designer
        'It can be modified using the Windows Form Designer.  
        'Do not modify it using the code editor.
        Friend WithEvents btnAfdrukken As System.Windows.Forms.Button
        Friend WithEvents Button1 As System.Windows.Forms.Button
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
            Me.btnAfdrukken = New System.Windows.Forms.Button
            Me.Button1 = New System.Windows.Forms.Button
            Me.SuspendLayout()
            '
            'btnAfdrukken
            '
            Me.btnAfdrukken.Location = New System.Drawing.Point(96, 24)
            Me.btnAfdrukken.Name = "btnAfdrukken"
            Me.btnAfdrukken.TabIndex = 0
            Me.btnAfdrukken.Text = "Afdrukken"
            '
            'Button1
            '
            Me.Button1.Location = New System.Drawing.Point(264, 24)
            Me.Button1.Name = "Button1"
            Me.Button1.TabIndex = 1
            Me.Button1.Text = "Button1"
            '
            'Form1
            '
            Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
            Me.ClientSize = New System.Drawing.Size(680, 502)
            Me.Controls.Add(Me.Button1)
            Me.Controls.Add(Me.btnAfdrukken)
            Me.Name = "Form1"
            Me.Text = "Form1"
            Me.ResumeLayout(False)
    
        End Sub
    
    #End Region
    
        Private Sub btnAfdrukken_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAfdrukken.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("C:\Documents and Settings\Joris\Bureaublad\Nieuwe map\GGIP\BierDatabase.mdb")
            moApp.RunCommand(Access.AcCommand.acCmdAppMaximize)
            moApp.DoCmd.Maximize()
            moApp.DoCmd.SetWarnings(False)
    
    
            moApp.DoCmd.OpenReport("rptBier", acViewPreview)
            moApp.CloseCurrentDatabase()
    
        End Sub
    End Class

  4. #44
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: printing access reports using vb.net

    Well you are previewing the report so if the user clicks print from the Access toolbar then it will print all pages. If they use the Print... from the File manu then they can designate the pages to print.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #45

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    115

    Re: printing access reports using vb.net

    Actually, it's not previewing anything, not even before I added the CloseCurrentDatabase.

    It all has to work out of the program, this fatso is too much of a lazy bum to learn how to use access, so I gotta make it in vb for him. So no file menu for me I guess..

  6. #46

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    115

    Re: printing access reports using vb.net

    I'm out for today, it's getting kinda late.
    I'll see you tomorrow I hope .

    My personal vb hero ^^

  7. #47
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: printing access reports using vb.net

    Np.

    There are two things more you can do.

    One: filter the reportsource query to only produce the final printed recordset needed and then .OpenReport passing the Normal view argument which is print.

    Two: call the printout method but that will print all the pages.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  8. #48

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    115

    Re: printing access reports using vb.net

    and how do I make that filter?

  9. #49
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: printing access reports using vb.net

    Add a where clause to the sql query that is your reportsource.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  10. #50

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    115

    Re: printing access reports using vb.net

    I'll see what I can do.

    Questions to come later

  11. #51
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: printing access reports using vb.net

    Ok, maybe in a new thread as its a bit of a different topic. Plus, other members may be more inclined to help in a new thread instead of reading through tweo pages of the original topic.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  12. #52

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    115

    Re: printing access reports using vb.net

    Ok, but still in the end thisis what the program is supposed to do, just so we're on the same page.

    Start up a self-made program, view the database in datagrids and be able to edit the database (already done).

    Be able to search something inside the same program using terms like "bee".
    Then the program should search everything which corresponds to *bee*.

    Be able to print the record which was looked up by the search function in the form of a report. Or either just be able to view the reports one by one in the program and print one to your own choice out.

    Last one: if you click "go back" in a window of the program after you made changes to the database, but didn't click on update there should be a pop-up window asking wether you want to quit, or go back and save the changes.
    Ofc if you click go back to save changes, you should go back and be able to save the changes.

    This is just what my program has to do in the end. Is it possible?

  13. #53
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: printing access reports using vb.net

    Second to last item, if they are to select a record out of the report then it should not be in a report (report records are not selectable in preview mode). Create a secondary form to display the query results and then what ever they check you can pass to the report for printing.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  14. #54

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    115

    Re: printing access reports using vb.net

    As long as it all happens inside the program, it's good.

  15. #55

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    115

    Re: printing access reports using vb.net

    Em like??
    the report corresponding to the record you selected in the datagrid I mean.. not a record out of a report. I'm not that stupid.
    Last edited by frederik; Mar 11th, 2007 at 10:35 AM.

  16. #56
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: printing access reports using vb.net

    I think its not checkable under the previous Access versions but test it just in case. 2007 you can check a checkbox in a report in preview view.

    Ps, didnt mean it that way.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  17. #57

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    115

    Re: printing access reports using vb.net

    Well, I'm going to come back at this on monday, after I saw my teacher. She might give a hint.

  18. #58

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    115

    Re: printing access reports using vb.net

    Ok, no hints :'(
    Is there a way to view the report inside the program?

    EVERYTHING HAS TO HAPPEN INSIDE THE PROGRAM, just to stay on the same page

  19. #59
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: printing access reports using vb.net

    So you are saying that you can not display Access at all?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  20. #60

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    115

    Re: printing access reports using vb.net

    Yes, that's what I'm saying.

    I think I got a crap work for school btw, I didn't choose to do this.

  21. #61
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 ???
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  22. #62

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    115

    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.

  23. #63
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: printing access reports using vb.net

    You could print the report directly to a secondary form or use the print preview control dialog.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  24. #64

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    115

    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.

  25. #65
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: printing access reports using vb.net

    Either one is about the same difficulty, not too easy but in .net
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  26. #66

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    115

    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.

  27. #67

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    115

    Re: printing access reports using vb.net

    NOOOOOEEEES my personal vb hero/guru left me!!

  28. #68
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  29. #69

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    115

    Re: printing access reports using vb.net

    Thanks, I'll try it.

  30. #70

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    115

    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 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 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 .

  31. #71

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    115

    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

  32. #72

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    115

    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.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width