Accessing Microsoft Access report database opens twice why?
Posted on 2012-04-13
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
Dim oAccess As Microsoft.Office.Interop.Access.Application
oAccess = CreateObject("Access.Application")
' Open the database
oAccess.DoCmd.OpenReport("Confirmation", 2, WhereCondition:="[Reservation_ReservationNum]=" & getreservation & "")
oAccess.Visible = True
Catch ex As Exception
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)
oAccess = Nothing