Advertisement

07.17.2008 at 10:34AM PDT, ID: 23574139
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.0

How to make connection global

Asked by tis9700 in Microsoft ADP, Microsoft Access Database, Access Coding/Macros

Tags: , , , ,

Hello,
I have several unbound forms in an ADP, each with it's own ADO connection calling a stored procedure.
I've heard that you should put your connection information (Standard Module?) in one place and call it to use for different forms but I'm not exactly sure how it's done. Could someone assist me?

Below is an example used on one of my forms from a command button...
So how do I put this in a module, then call the connection instead of having the connection in a bunch of different places?
The stored procedures are sometimes different depending on the form, as are the parameters.

Thanks

   Public Sub InsertClass

   Dim cn As New ADODB.Connection
   Dim rs As New ADODB.Recordset
   Dim cmd As New ADODB.Command
   Dim parm As New ADODB.Parameter

   On Error GoTo Error_Handler

   'Create a new ADO Connection object
   Set cn = New ADODB.Connection

    With cn
      .Provider = "Microsoft.Access.OLEDB.10.0"
      .Properties("Data Provider").Value = "SQLOLEDB"
      .Properties("Data Source").Value = "BH01WF54"
      .Properties("Initial Catalog").Value = "HS_PROG_DEV"
      .Properties("Integrated Security").Value = "SSPI"
      .Open
   End With

' Execute command to run stored procedure

    Set cmd = New ADODB.Command
    With cmd
        .ActiveConnection = cn
        .CommandType = adCmdStoredProc
        .CommandText = "usp_InsertClass"
        .CommandTimeout = 15
        .Parameters.Refresh
        .Parameters("@instID") = Me!instID
        .Parameters("@classDate") = Me!ClassDate
        .Parameters("@classType") = Me!ClassType
        .Parameters("@courseType") = Me!cboCourseType
        .Parameters("@classCounty") = Me!cboClassCounty
        .Parameters("@ttlHrsTaught") = Me!TtlHrsTaught
        .Parameters("@Enrolled") = Me!Enrolled
        .Parameters("@Graduated") = Me!Graduated
        .Parameters("@schoolHrs") = Me!schoolHrs
        .Parameters("@Males") = Me!Males
        .Parameters("@White") = Me!White
        .Parameters("@Black") = Me!Black
        .Parameters("@nativeAm") = Me!NativeAm
        .Parameters("@Hispanic") = Me!Hispanic
        .Parameters("@Other") = Me!Other
        .Parameters("@classComments") = Me!Comments
         Set rs = .Execute

    End With
   
    Do While rs.State = adStateClosed
      Set rs = rst.NextRecord
    Loop

   
    Me.ClassID = rs!ClassID

    If Me.ClassID = rs!ClassID Then
    MsgBox "Class record has been created. If present, enter Type 1 Assistants.", , "CONFIRMATION..."
    End If
   

    Set cmd = Nothing
    Set cn = Nothing

    Me.cmdAddAssistant.Visible = True

Exit Sub

Error_Handler:
    MsgBox Err.Description, vbExclamation, "VALID DATA ERROR.."

    Exit Sub
End subStart Free Trial
[+][-]07.17.2008 at 11:33AM PDT, ID: 22028562

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.21.2008 at 04:24AM PDT, ID: 22049470

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.21.2008 at 05:14AM PDT, ID: 22049702

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft ADP, Microsoft Access Database, Access Coding/Macros
Tags: Microsoft, Access, 2003, ADO connection in ADP to SQL Server 2000, vba
Sign Up Now!
Solution Provided By: vadimrapp1
Participating Experts: 1
Solution Grade: A
 
 
[+][-]08.04.2008 at 06:24AM PDT, ID: 22152173

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628