Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stepping Thru List Box Results

Status
Not open for further replies.

Spaniard

MIS
Jul 23, 2002
29
0
0
US
I have a list box that displays columns of dates (SchedBegin, SchedEnd). For verification purposes, I need to ensure that the new SchedBegin, SchedEnd does not conflict with the results displayed in the list box. How do I step through each of the records? I'm pretty sure that I am in the ballpark with the following code, but I need a little extra push.

Code:
Private Function IsDateClash(dtValue As Date) As Boolean
Dim ListControl As Counter
Dim bFlag As Boolean

ListControl = Me.lstPrevEntries.ListCount
bFlag = False

    Do
        Do While ListControl > 0
            If dtValue > Me.lstPrevEntries.Column(0) And dtValue < Me.lstPrevEntries.Column(1) Then  ' If condition is True.
                bFlag = False
                Exit Do
            End If
        Loop
    Loop Until bFlag = False
IsDateClash = bFlag
End Function

Thanks,
SWK.
 
I can't understand the meaning of the function at all, but let me give a try.
I only understand when u use the function in runtime and delete the information when the program shut down.
But I think that there's a table underlying the results. When it is, u can use
dim rst as new adodb.recordset, cnn as new adodb.connection
dim strSQL as string
strSQL = &quot;SELECT B_time, E_time from tblShed WHERE <criteria, new input date
rst.open strSQL,cnn, adopenkeyset, adlockreadonly
if not rst.bof then
msgbox &quot;Time just in use....&quot;
end if

 
I probably should have said that I'm working with Access 97, so I'm not sure I can use your approach (couldn't find any help topics). A query (of two tables) is providing the results to the list box. That correlates to your SQL statement. All I'm trying to do is to compare a new date to the ones in the list box - I'm just not sure how to step thru each record shown in the list box.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top