D
dave fernandez
I put the following function into an Access 2000
database. Now, when I quit the database, an instance of
the msaccess.exe process remains running. If I re-open
the database, reaccess the routine and quit again, there
are two instances running. If I open and use the database
but don't access the routine, msaccess.exe goes away.
Help please! Here is the routine:
Option Compare Database
Function FindSERecord(SONUMBERX, SOTYPEX, LINENUMBERX,
QUANTITYX) As Integer
On Error GoTo FindSERecord_Err
Dim CurConn As ADODB.Connection
Dim rst As ADODB.Recordset
' 0 = Record Found
' 1 = Record Added
' 2 = Error
FindSERecord = 0
Set CurConn = CurrentProject.Connection
Set rst = New ADODB.Recordset
rst.Open "SOEXTENSION", CurConn, adOpenKeyset,
adLockOptimistic, adCmdTableDirect
' Select the index used to order the data in the recordset
rst.Index = "PrimaryKey"
' Find the order where OrderId = 10255 and ProductId = 16
rst.Seek Array(SONUMBERX, SOTYPEX, LINENUMBERX),
adSeekFirstEQ
If rst.EOF Then
FindSERecord = 1
rst.AddNew
rst!SONUMBER = SONUMBERX
rst!SOTYPE = SOTYPEX
rst!LINENUMBER = LINENUMBERX
rst!GMT = QUANTITYX
rst.Update
rst.Close
CurConn.Close
Set rst = Nothing
Set CurConn = Nothing
Else
FindSERecord = 0
rst.Close
CurConn.Close
Set rst = Nothing
Set CurConn = Nothing
End If
FindSERecord_Err:
If Not rst Is Nothing Then
If rst.STATE = adStateOpen Then rst.Close
End If
Set rst = Nothing
If Not CurConn Is Nothing Then
If CurConn.STATE = adStateOpen Then CurConn.Close
End If
Set CurConn = Nothing
If Err <> 0 Then
MsgBox Err.Number & " " & Err.Description
FindSERecord = 2
End If
End Function
database. Now, when I quit the database, an instance of
the msaccess.exe process remains running. If I re-open
the database, reaccess the routine and quit again, there
are two instances running. If I open and use the database
but don't access the routine, msaccess.exe goes away.
Help please! Here is the routine:
Option Compare Database
Function FindSERecord(SONUMBERX, SOTYPEX, LINENUMBERX,
QUANTITYX) As Integer
On Error GoTo FindSERecord_Err
Dim CurConn As ADODB.Connection
Dim rst As ADODB.Recordset
' 0 = Record Found
' 1 = Record Added
' 2 = Error
FindSERecord = 0
Set CurConn = CurrentProject.Connection
Set rst = New ADODB.Recordset
rst.Open "SOEXTENSION", CurConn, adOpenKeyset,
adLockOptimistic, adCmdTableDirect
' Select the index used to order the data in the recordset
rst.Index = "PrimaryKey"
' Find the order where OrderId = 10255 and ProductId = 16
rst.Seek Array(SONUMBERX, SOTYPEX, LINENUMBERX),
adSeekFirstEQ
If rst.EOF Then
FindSERecord = 1
rst.AddNew
rst!SONUMBER = SONUMBERX
rst!SOTYPE = SOTYPEX
rst!LINENUMBER = LINENUMBERX
rst!GMT = QUANTITYX
rst.Update
rst.Close
CurConn.Close
Set rst = Nothing
Set CurConn = Nothing
Else
FindSERecord = 0
rst.Close
CurConn.Close
Set rst = Nothing
Set CurConn = Nothing
End If
FindSERecord_Err:
If Not rst Is Nothing Then
If rst.STATE = adStateOpen Then rst.Close
End If
Set rst = Nothing
If Not CurConn Is Nothing Then
If CurConn.STATE = adStateOpen Then CurConn.Close
End If
Set CurConn = Nothing
If Err <> 0 Then
MsgBox Err.Number & " " & Err.Description
FindSERecord = 2
End If
End Function