Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Accessing Microsoft Access report database opens twice why?

Posted on 2012-04-13
10
Medium Priority
?
453 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 58
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 2000 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 58
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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

688 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