Results 1 to 2 of 2

Thread: Printing Access report from VB.net 2012 Visual Studio Express

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2009
    Posts
    70

    Printing Access report from VB.net 2012 Visual Studio Express

    I have a VB front end created using an Access database. I created a report in Access that I would like to print from the front end. I have the following code:

    Code:
     Private Sub printsalesorder()
        Dim strWhere As String
            strWhere = CStr(txtsales.Text = """ & [Sales Order Number] & """"")
    
            acc = New Access.Application
            acc.OpenCurrentDatabase("C:\Users\dr18965\Documents\Visual Studio 2012\Projects\Crown Hardware\Crown_Hardware.mdb")
            acc.DoCmd.OpenReport("salesorder", Access.AcView.acViewNormal, , strWhere)
            acc.CloseCurrentDatabase()
            acc = Nothing
        End Sub
    Where I get a blank report with just teh labels and page header info or I use this code:
    Code:
     Private Sub printsalesorder()
           
    
            acc = New Access.Application
            acc.OpenCurrentDatabase("C:\Users\dr18965\Documents\Visual Studio 2012\Projects\Crown Hardware\Crown_Hardware.mdb")
            acc.DoCmd.OpenReport("salesorder", Access.AcView.acViewNormal)
            acc.CloseCurrentDatabase()
            acc = Nothing
        End Sub
    And it prints every record in the database. What I'm looking for is for it to just print the information that is entered at that moment. I understand that other versions of Visual Studio ( not express) has a report wizard but at this time I am using the express version.

  2. #2
    Frenzied Member
    Join Date
    May 2014
    Location
    Central Europe
    Posts
    1,286

    Re: Printing Access report from VB.net 2012 Visual Studio Express

    this looks odd:
    Code:
     strWhere = CStr(txtsales.Text = """ & [Sales Order Number] & """"")
    try:
    Code:
    Private Sub printsalesorder()
        Dim strWhere As String
            strWhere = CStr(txtsales.Text = """ & [Sales Order Number] & """"")
    
            acc = New Access.Application
            acc.OpenCurrentDatabase("C:\Users\dr18965\Documents\Visual Studio 2012\Projects\Crown Hardware\Crown_Hardware.mdb")
            messagebox.show(strWhere)
            acc.DoCmd.OpenReport("salesorder", Access.AcView.acViewNormal, , strWhere)
            acc.CloseCurrentDatabase()
            acc = Nothing
        End Sub

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