Solved

Access form stuck between open and load event

Posted on 2012-04-04
7
511 Views
Last Modified: 2012-04-05
Hello,

I have an access form that stalls between the open and load events.  I put a message box in the open event of the form and it fires.  However the load event never fires.  I've commented out all the code within the load event as well as compacted and repaired the database.  The form was working fine earlier in the day.  This form is populated via a linked sql server table (view).  The view opens fine when I open it by itself. This is a Access 2007 database
0
Comment
Question by:chtullu135
  • 4
  • 2
7 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 500 total points
ID: 37808636
Run this procedure on your db: (and post the code in the Open event)


Open the VBA Editor and from the menu ...Tools>>References ....
If you see any listed as **Missing: <reference name>, including the asterisks and the word Missing, the
you need to fix that first.

Then, follow this procedure:

****
0) **Backup your MDB BEFORE running this procedure**
****
1) Compact and Repair the MDB, as follows:
Hold down the Shift key and open the MDB, then from the menu >>Tools>>Database Utilities>>Compact and Repair ...
Close the mdb after the Compact & Repair.
2) Execute the Decompile (See example syntax below) >> after which, your database will reopen.
3) Close the mdb
4) Open the mdb and do a Compact and Repair (#1 above).
5) Close the mdb.
6) Open the mdb:
    a) Right click over a 'blank' area of the database window (container) and select Visual Basic Editor. A new window will open with the title 'Microsoft Visual Basic' ... followed by then name of your MDB.
    b) From the VBA Editor Menu at the top of the window:
       >>Debug>>Compile
        Note ... after the word Compile ...you will see the name of your 'Project' - just an fyi.

7) Close the mdb
8) Compact and Repair one more time.

*** Executing the DeCompile **EXAMPLE**:
Here is an **example** of the command line syntax  (be SURE to adjust your path and file name accordingly) before executing the decompile:

Run this from Start>>Run, enter the following command line - **all on one line** - it may appear like two lines here in the post:
Also, the double quotes are required.

"C:\Program Files\Microsoft Office\Office\Msaccess.exe" /decompile "C:\Access2003Clients\YourMdbNameHERE.mdb"

For more detail on the Decompile subject ... visit the Master on the subject (and other great stuff) Michael Kaplan:

http://www.trigeminal.com/usenet/usenet004.asp?1033

AND ...
Once you get familiar with the Decompile idea (and ALWAYS make a BACKUP first!) ... you can add both Decompile and Compact/Repair to the Right Click menus in Windows Explorer, which I use multiple times daily:

Getting the Decompile and Compact context menu options
http://access.mvps.org/access/modules/mdl0039.htm

mx
0
 

Author Comment

by:chtullu135
ID: 37808813
Hello mx,

I went ahead and went through the procedure you posted.  I was able to get the application going to now see where it was hanging up.  The form seemed to hang up when it hit PopulateMainComboBoxes.  This is the procedure I use to populate the comboboxes at runtime

Private Sub Form_Load

 ClearComboBoxes
 '   PopulateMainComboBoxes
 '   LoadRetrieve

End Sub

Private Sub PopulateMainComboBoxes
   Dim cnn as ADODB.Connection
   Dim rst As ADODB.Recordset
   
    Set cnn = New ADODB.Connection
    On Error Resume Next
   
   
    cnn.ConnectionString = cStrOLEDBConnectionString
    cnn.ConnectionTimeout = 0
    cnn.Open
    Set rst = cnn.Execute("dbo.spRetrieveGFPList")
    rst.MoveFirst
    Do While Not rst.EOF
        Me.cmbFilterByGFP.AddItem Nz(rst!GFP, "")
        rst.MoveNext
    Loop
   
    Set rst = cnn.Execute("dbo.spRetrieveWorkStreamList")
    rst.MoveFirst
    Do While Not rst.EOF
        Me.cmbFilterByWorkstream.AddItem Nz(rst!WorkStream, "")
        rst.MoveNext
    Loop
   
   
rst.Close
cnn.Close
Set rst = Nothing
Set cnn = Nothing


End Sub
0
 
LVL 75
ID: 37808821
ok ... so, where is ... it hanging up ?
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 77

Expert Comment

by:peter57r
ID: 37809870
I don't know if it's the way you copied and pasted your code into the question, but you appear to have created subs that don't have  () at the end of their declaration.. I don't know how it is possible to do that.  Can you check that your actual code does have the () for both procedures.
0
 

Author Comment

by:chtullu135
ID: 37811846
Yes I have () for both procedures.  One of the things I found was that I had the following line
On Error Resume Next
This was masking the actual problem which is a timeout error.  Upon further investigation, I found that the following stored procedure "dbo.spRetrieveGFPList" was running very slowly.  I'm now in the process of optimizing it.
0
 

Author Comment

by:chtullu135
ID: 37812142
Hello DatabaseMX,

It is hanging up on
Set rst = cnn.Execute("dbo.spRetrieveGFPList")

I am getting a timeout error.  I then executed the stored procedure and it took 40 seconds to complete.  It returned 17 rows
0
 

Author Closing Comment

by:chtullu135
ID: 37812783
Thanks for the help on the decompile.  That really helped to get the form up and running enough so I could trouble shooting.  I optimized the query and then set the connection command timout to 300 .  That portion of the form is now running great.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
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…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

747 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

10 Experts available now in Live!

Get 1:1 Help Now