R
ragtopcaddy via AccessMonster.com
I inherited the following code:
Function IsHistSim(Id As String, Type_Flag As String) As Boolean
Dim strSQL As String
Dim rstresults As Recordset
Dim RepoTicket As String
Dim tradescount As Integer
On Error GoTo ErrorProcess
' Change made to allow use on Dev box
'StrSql = " select rs.TicketNo from RepoSensitivity rs, FileControl fc "
& _
' " where rs.SequenceNo = 36876 " & _
' " and rs.TicketNo = ('" & RepoTicket & "') "
If Type_Flag = "TICKETHS" Then
strSQL = " select rs.LinkedTicketNo from Insight_Sensitivity rs " & _
" where ltrim(rtrim(rs.LinkedTicketNo)) = ('" & LTrim(RTrim
(Id)) & "') "
ElseIf Type_Flag = "MBSHS" Then
strSQL = " select rs.SecurityId from Insight_Sensitivity rs " & _
" where ltrim(rtrim(SensitivityType))='INPUTPLSTRIP%' AND rs.
SecurityId = (" & LTrim(RTrim(Id)) & ") "
ElseIf Type_Flag = "HCUT" Then
strSQL = " select rs.SecurityId from Insight_Sensitivity rs " & _
" where ltrim(rtrim(SensitivityType))='HCUT' AND rs.ValueUSD
is not null AND rs.SecurityId = (" & LTrim(RTrim(Id)) & ") "
End If
Set rstresults = dblocal.OpenRecordset(strSQL)
'Exit routine if no records are returned from Insight
If rstresults.RecordCount = 0 Then
rstresults.Close
IsHistSim = False
' Exit Function
GoTo Outtahere
End If
IsHistSim = True
rstresults.Close
Exit Function
ErrorProcess:
IsHistSim = False
rstresults.Close
Exit Function
Outtahere:
End Function
Regardless of whether it executes "Exit Function" or "GoTo Outtahere", the
code immediately steps right back to "Function IsHistSim(Id As String,
Type_Flag As String) As Boolean" and begins execution all over again. I can't
figure out why it doesn't obediently exit or end the function as coded.
Any ideas?
Function IsHistSim(Id As String, Type_Flag As String) As Boolean
Dim strSQL As String
Dim rstresults As Recordset
Dim RepoTicket As String
Dim tradescount As Integer
On Error GoTo ErrorProcess
' Change made to allow use on Dev box
'StrSql = " select rs.TicketNo from RepoSensitivity rs, FileControl fc "
& _
' " where rs.SequenceNo = 36876 " & _
' " and rs.TicketNo = ('" & RepoTicket & "') "
If Type_Flag = "TICKETHS" Then
strSQL = " select rs.LinkedTicketNo from Insight_Sensitivity rs " & _
" where ltrim(rtrim(rs.LinkedTicketNo)) = ('" & LTrim(RTrim
(Id)) & "') "
ElseIf Type_Flag = "MBSHS" Then
strSQL = " select rs.SecurityId from Insight_Sensitivity rs " & _
" where ltrim(rtrim(SensitivityType))='INPUTPLSTRIP%' AND rs.
SecurityId = (" & LTrim(RTrim(Id)) & ") "
ElseIf Type_Flag = "HCUT" Then
strSQL = " select rs.SecurityId from Insight_Sensitivity rs " & _
" where ltrim(rtrim(SensitivityType))='HCUT' AND rs.ValueUSD
is not null AND rs.SecurityId = (" & LTrim(RTrim(Id)) & ") "
End If
Set rstresults = dblocal.OpenRecordset(strSQL)
'Exit routine if no records are returned from Insight
If rstresults.RecordCount = 0 Then
rstresults.Close
IsHistSim = False
' Exit Function
GoTo Outtahere
End If
IsHistSim = True
rstresults.Close
Exit Function
ErrorProcess:
IsHistSim = False
rstresults.Close
Exit Function
Outtahere:
End Function
Regardless of whether it executes "Exit Function" or "GoTo Outtahere", the
code immediately steps right back to "Function IsHistSim(Id As String,
Type_Flag As String) As Boolean" and begins execution all over again. I can't
figure out why it doesn't obediently exit or end the function as coded.
Any ideas?