Has anyone experienced NO OPEN errors when trying to use the maximizer odbc driver to open a connection to a database and create an opportunity through the OpportunityHook? I only get them when i'm trying to run the hook as normal, however in debug mode I do not get these NO OPEN errors. The errors are described more clearly below with code snippets.
Platform: Windows 2000
Maximizer Enterprise 7.5
Code Example:
Public Function OpportunityInsert(ByVal MaxApp As Application, ByVal MaxRec As CurrentRecord, ByVal MaxOms As OMS, ByVal ParentHwnd As Long, ByVal rights As Boolean, ByVal reserved As Long) As Boolean
' MsgBox "OpportunityInsert invoked
'Set global values
Set oMaxApp = MaxApp 'Sets the Application object from the app
Set cr = MaxRec 'Sets the CurrentRecord object from the app
Set opp = MaxOms 'Sets the OMS object from the app
hWndFrame = ParentHwnd 'Pass the app's Parent Window Handle down.
Set ClientForm = New frmOpportunityAdd
ClientForm.Show 1
'Release global objects
Set oMaxApp = Nothing
Set cr = Nothing
Set opp = Nothing
OpportunityInsert = True
End Function
My AddOpportunity function in teh Maxdecl Module file:
Function AddOpportunity()
MsgBox (oMaxApp.GetActiveWindow)
Dim SQLInstruction As String
Dim ClientID As String
Dim ContactNo As String
ClientID = cr.GetFieldValue("IDentification")
Dim oConn As ADODB.Connection
Dim strCnn As String
Set oConn = New ADODB.Connection ' connection object
strCnn = "DSN=Centrepoint;User ID=MASTER;Password=control;"
'NO OPEN errors seem to start happening here? When oConn.Open is called
oConn.Open strCnn ' connect to database
Dim oRst As Recordset
Set oRst = New ADODB.Recordset
oRst.Open "SELECT * From Opportunity Where Opp_ID = '666'", oConn, adOpenKeyset, adLockOptimistic
oRst.AddNew
oRst.Fields("Client_ID") = ClientID
oRst.Fields("Objective") = "New Opportunity"
oRst.Fields("Team_Id") = -1
oRst.Update
oRst.Close
Set oRst = Nothing
oConn.Close
Set oRst = Nothing
Set oConn = Nothing
End Function
My OK button code within the form which calls the function above!
Private Sub cmdOK_Click()
Call AddOpportunity
End Sub
The errors as follow:
DataManager returned an error code of 3.
A NO OPEN error occured on the 'User Defined fields' file.
I click OK
DataManager returned an error code 3.
A NO OPEN error occured on the 'Opportunities and Campaigns' File
I click OK
DataManager returned an error code 3.
A NO OPEN error occured on the 'Link File' file.
Thanks
Ryan.
Original Post