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


Form.shown Event speed

Posted on 2014-11-10
Medium Priority
Last Modified: 2014-12-04

I've moved all my code from my startup form form_load event to the form_shown event because I was having problem with crystal reports in other forms giving me a  "crystal report print Attempted to read or write protected memory. This is often an indication that other memory is corrupt." Every time I was printing or exporting a report

This has fixed the crystal reports issues I was having, the only thing is that now the startup form seems take more time to load, it seems to start "stuck" and then loads everything.

Though personally I don't mind the delay, some users might and I was wondering if there was a way to speed it up a little being that it is in the form_shown event?

Thank you,
Question by:FCapo
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
  • 5
LVL 101

Expert Comment

ID: 40433845
Are you rendering the report when the form is loaded?

LVL 18

Expert Comment

ID: 40433872
You should create a separate thread and load the report there. This will not slow the form

Author Comment

ID: 40435138
Hi, the following code is in the form_shown event, I have no reports on this form, this is simply my start up form, the reports are located in other forms in my app;

I have no idea why but if I keep the following code in the form_load event it crashes my application when I try to open the forms that do have reports with "crystal report print Attempted to read or write protected memory. This is often an indication that other memory is corrupt." :

having it in the Form1_Shown event seems to solve the crash but it creates a delay when the start up form is first shown

Private Sub Form1_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown

        clientData = New Clients
        cliDataSet = clientData.getCliDataSet
        cliBindingSource = New BindingSource

        clientDataExtra = New clientsExtra
        clidatasetExtra = clientDataExtra.getCliDataSet
        cliBindingSourceExtra = New BindingSource

        rectAccessData = New ClientsAccess
        recAccDataSet = rectAccessData.getRecDataSet
        AccessBindingsource = New BindingSource

        clientAccessData = New ClientsAccess
        cliAccDataSet = clientAccessData.getrelateddata
        cliAccessBindingsource = New BindingSource

        timeData = New timesheet
        timeDataSet = timeData.getTimesheetHoursDataSet
        timeBindingSource = New BindingSource

        timeData1 = New timesheet
        timeDataSet1 = timeData1.getTimesheetHoursDataSet2
        timeBindingSource1 = New BindingSource

        budgetData = New ClientsAccess
        budgetdataset = budgetData.getBudget
        budgetBindingsource = New BindingSource

        With cliAccessBindingsource
            .DataSource = cliAccDataSet
            .DataMember = "projets"
        End With

        With budgetBindingsource
            .DataSource = budgetdataset
            .DataMember = "budget"
        End With

        With timeBindingSource
            .DataSource = timeDataSet
            .DataMember = "FeuillesDeTemps"
            .Sort = "ID"
        End With

        With timeBindingSource1
            .DataSource = timeDataSet1
            .DataMember = "FeuillesDeTemps"
            .Sort = "ID"
        End With

        With AccessBindingsource
            .DataSource = recAccDataSet
            .DataMember = "recevable"
        End With

        With cliBindingSource
            .DataSource = cliDataSet
            .DataMember = "DataTable"
            .Sort = "sName"
        End With

        With cliBindingSourceExtra
            .DataSource = clidatasetExtra
            .DataMember = "DataTable1"
        End With

        With cliCbx
            .DataSource = cliBindingSource
            .DataBindings.Add("text", cliBindingSource, "sName", False, DataSourceUpdateMode.Never)
            .DisplayMember = "sName"
        End With

        With extraCbx
            .DataSource = cliBindingSourceExtra
            .DataBindings.Add("text", cliBindingSourceExtra, "lCusId", False, DataSourceUpdateMode.Never)
            .DisplayMember = "lCusId"
        End With

        DataGridView1.DataSource = cliBindingSource

        For i = 0 To DataGridView1.Columns.Count - 1
            If i = 1 Then
                DataGridView1.Columns(i).Visible = False
            End If

        DataGridView1.Columns(1).HeaderText = "Nom du client"
        DataGridView1.Columns(1).AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill

        SimpleId.DataBindings.Add("text", cliBindingSource, "lId")
        cliSimplyExtra.DataBindings.Add("text", cliBindingSourceExtra, "lCusId")

        cliRue1.DataBindings.Add("text", cliBindingSource, "sStreet1")
        cliRue2.DataBindings.Add("text", cliBindingSource, "sStreet2")
        cliVille.DataBindings.Add("text", cliBindingSource, "sCity")
        cliPrv.DataBindings.Add("text", cliBindingSource, "sProvState")
        cliCode.DataBindings.Add("text", cliBindingSource, "sPostalZip")
        cliCourriel.DataBindings.Add("text", cliBindingSource, "sEmail")
        CliTxt.DataBindings.Add("text", cliBindingSource, "sCntcName")
        cliTelBur.DataBindings.Add("text", cliBindingSource, "sPhone1")
        cliTelCell.DataBindings.Add("text", cliBindingSource, "sPhone2")
        cliFax.DataBindings.Add("text", cliBindingSource, "sFax")
        cliTelDom.DataBindings.Add("text", cliBindingSourceExtra, "sUsrDfnd1")


        If My.Settings.recevReminders = "yes" Then
        End If

        If My.Settings.timesheetReminders = "yes" Then
            My.Settings.timesheetId = timeDataSet.FeuillesDeTemps.Compute("max(ID)", "")
        End If

        TabControl1.SelectedIndex = 1
        TabControl1.SelectedIndex = 0

    End Sub

Open in new window

Implementing Azure Infrastructure Exam 70-533

This course is designed to familiarize and instruct students in the content that is covered by Microsoft Exam 70-533, Implementing Microsoft Azure Solutions. It focuses on all the November 2016 objective domain topics.


Author Comment

ID: 40437831
Any ideas?

Why does having my code in the startup Form1_Shown instead of Form1_load event impact crystal reports being able to print or export in another form?
LVL 101

Accepted Solution

mlmcc earned 2000 total points
ID: 40437860
I have no idea.

Most likely it is because of when the event fires in relation to when the report loads


Author Comment

ID: 40438769
After looking further,

I've come to the conclusion that it has to do with the Access format of my database, which is .ACCDB

I've tried converting it to the standard .MDB version and updating it in my datasets, afterwards crystal report was no longer giving me this error when printing or exporting;

I've attached a screenshot of how Crystal Reports is set to connect to my database, when switching over from Provider=Microsoft.ACE.OLEDB.12.0  to Provider=Microsoft.Jet.OLEDB.4.0 it seemed to no longer give me this error.

I rather keep the .ACCDB since I have a few apps connecting to it, hopefully you can look at the screencapture and there may be a different way to connect to it that wouldn't provoke this error?

Thank you
LVL 101

Expert Comment

ID: 40439114
What version of Crystal?

DId you download the Office database connectors?


Author Comment

ID: 40440130
I have the full crystal report version running with visual studio 2010 and the crystal reports Support Pack 12 (v.

Yes I believe I have the right Office database connectors, I only get these issues when crystal reports sees more than one connection is made to the .ACCDB database, using the JET connection crystal reports doesn't give me any issues...
LVL 101

Assisted Solution

mlmcc earned 2000 total points
ID: 40440606
CR XI R2 ( was built for .Net 2.0.  Are you running in a later .Net framework?

You probably want to change the reports to use the .Net version


Author Comment

ID: 40440921
I'm running .net framework 4, How can I about changing the report to use the .Net version? Is there a setting I can change somewhere?

Thank you
LVL 101

Assisted Solution

mlmcc earned 2000 total points
ID: 40441463
You should be able to install the CR for .Net then import the report into the application and save it.


Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

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…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA:…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

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