troubleshooting Question

MS Access ADP (xp / 2003) Loses Connection - How to Reconnect

Avatar of gj99116
gj99116 asked on
Microsoft Access
7 Comments2 Solutions1589 ViewsLast Modified:
I have a MS SQL Server database that is being used as the backend for an MS Access ADP file.  I used the File, Connection to specify the server information.  For most of the Forms I have used stored procedures and called them with VB using code similar to the code below:

Dim cnn As Connection
Set cnn = CurrentProject.Connection
    Dim rstWipJob As Recordset
    Dim rstPrmWIPJ As ADODB.Parameter
    Set rstComWIPJ = New ADODB.Command
    rstComWIPJ.ActiveConnection = cnn
    With rstComWIPJ
        .ActiveConnection = CurrentProject.Connection
        .CommandText = "JobNumLookup"
        .CommandType = adCmdStoredProc
        Set rstPrmWIPJ = .CreateParameter("@WipJobNum", _
            adVarChar, adParamInput, 30)

    rstPrmWIPJ = Me![WIPJobNum]
        .Parameters.Append rstPrmWIPJ
    End With
    Set rstWipJob = rstComWIPJ.Execute

This seems to work perfectly as it executes the Stored Procedure and passes the variable exactly as I expected it to.  If I am making any errors or there is a better way too do this please let me know...  There are a few Forms that someone else defined that take data (and it is verified) but simply use the DoCmd .Close command to save the data rather than actually executing an SQL command or SP.  I don't know if allowing these forms to use the DoCmd.Close method of saving is a problem or not?

My main problem is that some of the clients use wireless to access the application.  For the most part this works perfectly fine but occaisionally the database goes to a "Disconnected" state.  I believe this typically happens if the user doesn't use the application for a long time (power settings relating to battery life may cause it to standby or hibernate.)  What is the best way (even if it means changing the way I am creating connections etc. in my code) to reconnect the database when it goes into this offline state?

Some of the buttons open forms using Stored Procedures (to filter down to a specific record) and some use the Do.Cmd saving method instead of an actual Insert or Update statement sent via a connection and recordset object.

Can anyone offer some help?  Is using the syntax above acceptable?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros