473,406 Members | 2,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

list box problem!!!!!!!!

52
hi,
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
  1. Private Sub Form_Load()
  2. '
  3. Dim s() As String
  4. Dim ListTime As String
  5. Dim ListDate As String
  6. Dim name As String
  7. Dim i As Integer
  8.     Set dbReminder = OpenDatabase(App.Path & "\Password.mdb")
  9.     Set rsReminder = dbReminder.OpenRecordset("Reminder", dbOpenDynaset)
  10.  
  11. If Not rsReminder.EOF Then rsReminder.MoveFirst
  12.  
  13. Do While Not rsReminder.EOF
  14.     lstReminder.AddItem rsReminder!Rno & "." & " " & rsReminder!name & vbTab & vbTab & rsReminder!Date & vbTab & rsReminder!TIME
  15.     lstReminder.ItemData(lstReminder.NewIndex) = rsReminder!Rno
  16.     rsReminder.MoveNext
  17. Loop
  18.  
  19.     Set dbReminder = OpenDatabase(App.Path & "\Password.mdb")
  20.     Set rsReminder = dbReminder.OpenRecordset("Reminder", dbOpenDynaset)
  21.  
  22. For i = 0 To lstReminder.ListCount - 1
  23. s = Split(lstReminder.List(i), vbTab)
  24. 'name = Mid(s(UBound(s)))
  25. ListTime = Mid(s(UBound(s)), 1, Len(s(UBound(s))) - 3)
  26. ListDate = s(UBound(s) - 1)
  27. 'MsgBox name = Mid(s(UBound(s)), 1, Len(s(UBound(s))))
  28. If ListTime = Mid(TIME, 1, Len(TIME) - 3) And ListDate = Date Then
  29.    MsgBox rsReminder!Name
  30. End If
  31.  
  32. Next
  33. End Sub
  34.  
  35. LIST BOX
  36. Private Sub lstReminder_Click()
  37. '
  38. rsReminder.FindFirst "Rno=" & (lstReminder.ItemData(lstReminder.ListIndex))
  39.  
  40. rsReminder!Rno = frmReminder.txtno.Text
  41. rsReminder!name = frmReminder.txtName.Text
  42. rsReminder!Date = frmReminder.txtDate.Text
  43. rsReminder!TIME = frmReminder.txtTime.Text
  44. rsReminder!Comments = frmReminder.txtComment.Text
  45. End Sub
  46.  
in the for statement this is where the mesage is shown " MsgBox rsReminder!Name"
please can you explain why it only shows the first item on the list.
Apr 21 '08 #1
1 1092
jeffstl
432 Expert 256MB
I believe that is because you are using the recordset on the MsgBox line instead of the lstbox data set.

You are looping through your listbox, not your recordset so you need to use the when you use rsReminder!name you are only displaying the first record in the recordset, rather then which one you are on in the listbox.....

You may need to do a sql select to get the "reminder name" from your recordset based on a key from your list box maybe. i guess unless you have the name in your list box.


Expand|Select|Wrap|Line Numbers
  1. For i = 0 To lstReminder.ListCount - 1
  2.      s = Split(lstReminder.List(i), vbTab)
  3.      'name = Mid(s(UBound(s)))
  4.      ListTime = Mid(s(UBound(s)), 1, Len(s(UBound(s))) - 3)
  5.      ListDate = s(UBound(s) - 1)
  6.      'MsgBox name = Mid(s(UBound(s)), 1, Len(s(UBound(s))))
  7.      If ListTime = Mid(TIME, 1, Len(TIME) - 3) And ListDate = Date Then
  8.              MsgBox rsReminder!Name 'this is from your recordset which will be set to the first record, you would need to find the correct record to display
  9.      End If
  10. Next
  11.  
Apr 23 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: emanshu | last post by:
Hi all, i am facing some problems with list.. i am receiving some data from some sender and i am storing this data in to list. i am receiving and storing all the packets in the list till i...
5
by: John N. | last post by:
Hi All, Here I have a linked list each containing a char and is double linked. Then I have a pointer to an item in that list which is the current insertion point. In this funtion, the user...
10
by: Ben | last post by:
Hi, I am a newbie with C and am trying to get a simple linked list working for my program. The structure of each linked list stores the char *data and *next referencing to the next link. The...
16
by: Shwetabh | last post by:
Hi, This is a question asked to me in an interview. I haven't been able to figure out an answer for it. Please try to see what can be done about the following problem. /* I have been given two...
3
by: pmud | last post by:
Hi, I have 2 drop down lists on an asp.Net page. The 1st contains alphabets. When the user selects an alphabet frm the first list, the second drop down list should be populated with names from...
11
by: bofh1234 | last post by:
Hello, I am having a problem with linked lists. My program is based on a client server model. The client sends some packets of data to the server. The server reads those packets and is...
3
by: kevndcks | last post by:
For example i write the following code in the Python command line; Then enter this command, which will then return the following; Now the problem, reading through the Python tutorial's,...
2
by: sieg1974 | last post by:
Hi, I have a linked list with 705 nodes, and the functions getContact and listContact to deal with it. listContact works properly, and prints all some debug information about each node. On the...
5
by: Michael | last post by:
Hi All, I've wasted heaps of time today trying to get some code I copied from a text to compile. I have cut it down to the following couple of lines which demonstrate the core of the problem: ...
1
by: Radenko Zec | last post by:
Hi i have generic list problem with DAL code. class UlazTotal {
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.