Solved

Accessing Microsoft Access report database opens twice why?

Posted on 2012-04-13
10
431 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
  • 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
 
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now