Solved

Accessing Microsoft Access report database opens twice why?

Posted on 2012-04-13
10
445 Views
Last Modified: 2012-04-18
Good Afternoon,

I have a vb.net application with an access database backend.  Database is old and has been converted up to 2003 I think but it originated from an older version of access than 2003.

I have been given no choice other than to build the front end for the reservations and to use existing reports that sit inside the database.

I have all working BUT when one of the reports is called for preview with the below (using linkbutton inside gridview) the database and report open TWICE.  My questions are does anyone know why?  If so can you tell me what I am doing wrong?  If not is there any other way to do this in vb.net using the existing reports?


Public Sub thesearchresults_RowCommand(ByVal o As Object, ByVal e As GridViewCommandEventArgs) Handles thesearchresults.RowCommand

        If e.CommandName = "view" Then
            Dim index As Integer = Convert.ToInt32(e.CommandArgument)
            Dim row As GridViewRow = thesearchresults.Rows(index)
            Dim getreservation As Integer = row.Cells(1).Text
            'MsgBox(getreservation)
            Try

                Dim oAccess As Microsoft.Office.Interop.Access.Application
             oAccess = CreateObject("Access.Application")

                ' Open the database
             oAccess.OpenCurrentDatabase(dblocation)
             oAccess.DoCmd.OpenReport("Confirmation", 2, WhereCondition:="[Reservation_ReservationNum]=" & getreservation & "")
 
                oAccess.DoCmd.Maximize()
                oAccess.Visible = True
            Catch ex As Exception
                'MsgBox(ex.Message)
                'MsgBox(ex.StackTrace)
                errhandler.WriteError("manage-reservation.aspx and procedure is thesearchresults rowcommand and user is " & Session("theuser"), ex.Message & " " & ex.StackTrace)
                Response.Redirect("CustomError.aspx?thetype=" & ex.Message)
            Finally
                oAccess = Nothing
            End Try
            End If
    End Sub
0
Comment
Question by:thamilto0410
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 57
ID: 37844207
It's just this one report?   The above code looks fine...I don't see any issues.

Jim.
0
 
LVL 1

Author Comment

by:thamilto0410
ID: 37844843
JDettman--So far it is just this one report.  I have many others in this access DB I inherited but so far the others I only need to generate a printout which works well ie:open db send to printer close db.  For this report the user needs the ability to preview and when I open for preview the DB opens and displays report twice.
0
 
LVL 5

Expert Comment

by:DoveTails
ID: 37845627
Sounding like the report may be the issue.
Any chance there's something going on with the report itself ?....
such as code for a text box that fits multiple records    ie.   IIf([Field])="1","2"
0
Report: Liquid Web beats Amazon, Rackspace & More

A study by performance analyst firm Cloud Spectator finds that Liquid Web beats rivals Amazon, Rackspace and DigitalOcean when it comes to website and cloud application performance.

 
LVL 1

Author Comment

by:thamilto0410
ID: 37846131
DoveTails:  As I haven't worked with Access or its reports for many years (primarily develop with Oracle) I had not thought of that.  I will tear the report down looking for trouble and let you know.  Thanks.
0
 
LVL 57
ID: 37846268
Yes, I would try and use a copy of Access and see if the report opens normally there.

Jim.
0
 
LVL 1

Author Comment

by:thamilto0410
ID: 37857983
JDettman :  The report does open normally in access and there is not anything wrong with the query it does run and populate the report with all fields pulled in the only problem is that in the vb app the db opens twice and the report displays twice.  

Any other suggestions from anyone?
0
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 37858028
Any chance your code is getting called 2x?  Put a message box up or something when you run through the routine to see if it's getting called twice.

Jim.
0
 
LVL 1

Author Comment

by:thamilto0410
ID: 37858620
JDettman:  You are correct.  I put in the msgbox and it displays twice so the procedure is getting called twice.  I am using a linkbutton and onrowcommand.  so what do I do change to something else?
0
 
LVL 1

Author Closing Comment

by:thamilto0410
ID: 37860280
Thank you JDETTMAN.  I figured it out.  I AM AN IDIOT.  Your last post about the procedure getting called twice helped me to get my head out of the clouds and stop blaming it on the DB and to go over the code again and I KNOW NOT TO call the procedure in the gridview and in the codebehind but I had accidentally done that and then could not see the forest for the trees.  THANKS SO MUCH.
0
 
LVL 57
ID: 37860435
I wouldn't call yourself an idot; stuff like that is easy to do!  Programming is a complicated business and computers never let you forget a mistake<g>.  You should see some of the ones I've pulled over the years...

Glad to hear you've got it figured out.

Jim.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
The viewer will learn how to dynamically set the form action using jQuery.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question