Scott Marcus 
      marcus at tsstech.com
      
      Mon Aug 30 08:34:44 CDT 2004
    
Why would the following function work the first time it is called but hang on subsequent calls? It locks up on the OpenRecordset statement. I've tried variations on the OpenRecordset statement [such as Set rst = qdf.OpenRecordset()]. This is connecting to an Oracle database. Watch for line wrap.
Public Function GetEmployee(strEmployeeNo As String, ByRef strName As String) As Boolean
On Error GoTo HandleError
Dim qdf As QueryDef
Dim rst As Recordset
GetEmployee = False
Set qdf = CurrentDb.CreateQueryDef("")
qdf.Connect = "ODBC;DSN=dataconnection;UID=user;PWD=password;DBQ=uxs02;DBA=R;APA=T;PFC=1;TLO=0;"
qdf.SQL = "SELECT surname, given_name FROM employees WHERE employeeno = '" & strEmployeeNo & "';"
Set rst = qdf.OpenRecordset(dbOpenForwardOnly, dbSQLPassThrough)
If rst.EOF <> True Then
    GetEmployee = True
    strName = Trim(rst!given_name) & " " & Trim(rst!surname)
End If
rst.Close
Set rst = Nothing
qdf.Close
Set qdf = Nothing
Exit Function
HandleError:
Call Log(Err.Number & ": " & Err.Description, "modEmployeeManagement:GetEmployee")
End Function
Thanks in advance,
Scott Marcus
TSS Technologies