Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Cannot hit the if condition by function's return value

Posted on 2006-05-15
1
Medium Priority
?
152 Views
Last Modified: 2010-05-01
                       If CheckTSTrend(temptimeStart, recid) = True Then
                            'Get data and upload
                            GetTrendData pqdifLogicalObj, pRecordObserv, TrendData
                        End If

Cannot get to the  GetTrendData, though CheckTSTrend is true

The function is as below,

    MyRs.Open strSQL, cn
    If Not MyRs.EOF Then
        If CStr(timeStart) > MyRs(0) Then
            CheckTSEvent = True
        Else
            CheckTSEvent = False
        End If
    End If
   
'    cmd.Execute
    cn.CommitTrans
    cn.Close

End Function
0
Comment
Question by:turbot_yu
1 Comment
 
LVL 44

Accepted Solution

by:
bruintje earned 2000 total points
ID: 16681181
Hello turbot_yu,

you need to return the value in the function call, else it will not return the CheckTSEvent value and always return falsse
CheckTSTrend = CheckTSEvent

something like

Function CheckTSTrend(val1, val2)
MyRs.Open strSQL, cn
    If Not MyRs.EOF Then
        If CStr(timeStart) > MyRs(0) Then
            CheckTSEvent = True
        Else
            CheckTSEvent = False
        End If
    End If
   
'    cmd.Execute
    cn.CommitTrans
    cn.Close

  CheckTSTrend = CheckTSEvent

End Function

hope this helps a bit
bruintje
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month15 days, 11 hours left to enroll

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question