T
TastyWheat
I have a function inside a module. It's a pretty standard lookup
function and I've used very similar code in all of my databases. For
some reason, everytime I run the code my process (MSACCESS.EXE) doesn't
finish on its own. I click the 'X' or select 'Exit' and the window
goes away. The only way I can kill the process is to use the task
manager. Here's my code:
===============================
Public Function GetEmployeeStore(lngEmployee As Long) As Long
On Error GoTo GetEmployeeStore_Error
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strSQL As String
Dim strTable As String
Set conn = CurrentProject.Connection
strTable = "[Store Change]"
strSQL = "SELECT * " & _
"FROM " & strTable & ";"
Set rs = New ADODB.Recordset
Set rs.ActiveConnection = conn
rs.CursorType = adOpenStatic
rs.Source = strSQL
rs.Open
GetEmployeeStore = rs("NewStoreID")
GetEmployeeStore_End:
If Not (rs Is Nothing) Then
If Not (rs.State = adStateClosed) Then
rs.Cancel
rs.Close
End If
End If
Set acc = Nothing
Set rs = Nothing
Set conn = Nothing
Exit Function
GetEmployeeStore_Error:
GoTo GetEmployeeStore_End
End Function
===============================
function and I've used very similar code in all of my databases. For
some reason, everytime I run the code my process (MSACCESS.EXE) doesn't
finish on its own. I click the 'X' or select 'Exit' and the window
goes away. The only way I can kill the process is to use the task
manager. Here's my code:
===============================
Public Function GetEmployeeStore(lngEmployee As Long) As Long
On Error GoTo GetEmployeeStore_Error
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strSQL As String
Dim strTable As String
Set conn = CurrentProject.Connection
strTable = "[Store Change]"
strSQL = "SELECT * " & _
"FROM " & strTable & ";"
Set rs = New ADODB.Recordset
Set rs.ActiveConnection = conn
rs.CursorType = adOpenStatic
rs.Source = strSQL
rs.Open
GetEmployeeStore = rs("NewStoreID")
GetEmployeeStore_End:
If Not (rs Is Nothing) Then
If Not (rs.State = adStateClosed) Then
rs.Cancel
rs.Close
End If
End If
Set acc = Nothing
Set rs = Nothing
Set conn = Nothing
Exit Function
GetEmployeeStore_Error:
GoTo GetEmployeeStore_End
End Function
===============================