i'm trying to create a reminder form on vb6 with access holding the reminders.
i was given a code that checks the list box where all the reminders are shown on vb to see if any of the reminders match the actual time and date.
my problem is that if there is a reminder that matches the actual time and date then the message box will show but the item shown in the message box is always the one on the top of the list.
this is my form load and my listbox code:
FORM LOAD
Expand|Select|Wrap|Line Numbers
- Private Sub Form_Load()
- '
- Dim s() As String
- Dim ListTime As String
- Dim ListDate As String
- Dim name As String
- Dim i As Integer
- Set dbReminder = OpenDatabase(App.Path & "\Password.mdb")
- Set rsReminder = dbReminder.OpenRecordset("Reminder", dbOpenDynaset)
- If Not rsReminder.EOF Then rsReminder.MoveFirst
- Do While Not rsReminder.EOF
- lstReminder.AddItem rsReminder!Rno & "." & " " & rsReminder!name & vbTab & vbTab & rsReminder!Date & vbTab & rsReminder!TIME
- lstReminder.ItemData(lstReminder.NewIndex) = rsReminder!Rno
- rsReminder.MoveNext
- Loop
- Set dbReminder = OpenDatabase(App.Path & "\Password.mdb")
- Set rsReminder = dbReminder.OpenRecordset("Reminder", dbOpenDynaset)
- For i = 0 To lstReminder.ListCount - 1
- s = Split(lstReminder.List(i), vbTab)
- 'name = Mid(s(UBound(s)))
- ListTime = Mid(s(UBound(s)), 1, Len(s(UBound(s))) - 3)
- ListDate = s(UBound(s) - 1)
- 'MsgBox name = Mid(s(UBound(s)), 1, Len(s(UBound(s))))
- If ListTime = Mid(TIME, 1, Len(TIME) - 3) And ListDate = Date Then
- MsgBox rsReminder!Name
- End If
- Next
- End Sub
- LIST BOX
- Private Sub lstReminder_Click()
- '
- rsReminder.FindFirst "Rno=" & (lstReminder.ItemData(lstReminder.ListIndex))
- rsReminder!Rno = frmReminder.txtno.Text
- rsReminder!name = frmReminder.txtName.Text
- rsReminder!Date = frmReminder.txtDate.Text
- rsReminder!TIME = frmReminder.txtTime.Text
- rsReminder!Comments = frmReminder.txtComment.Text
- End Sub
please can you explain why it only shows the first item on the list.