PcLinuxGuru
Technical User
I have trying to pull data from a database, list it in a list box, and when a user clicks on an entry in the listbox the data populates the fields I have setup.
Now this work with no problems if there are no duplicate entries but I have several duplicate entries for the list box. I am not sure how to code in to get the data I actually need. This is what I have that actually works. I am use a DataControl BTW.
I have 2 fields an ID & Amount in my access db. User types in Acct. Number to search for and when they click search it populates the list box with Amounts (I did not format it for currency yet). Which works. The list box get filled correctly. The problem is in selecting a record from the list box. If I have 3 or more 4.47 then it won't show the correct record in my text fields.
I am not sure how to go about getting the results I need.
Now this work with no problems if there are no duplicate entries but I have several duplicate entries for the list box. I am not sure how to code in to get the data I actually need. This is what I have that actually works. I am use a DataControl BTW.
I have 2 fields an ID & Amount in my access db. User types in Acct. Number to search for and when they click search it populates the list box with Amounts (I did not format it for currency yet). Which works. The list box get filled correctly. The problem is in selecting a record from the list box. If I have 3 or more 4.47 then it won't show the correct record in my text fields.
Code:
Private Sub cmdSearch_Click()
Dim strQueryString As String
strQueryString = "ID =" & ID.Text
lstData.Clear ' Clear the Accounts list box
datData.Recordset.FindFirst strQueryString
Do Until datData.Recordset.NoMatch
lstData.AddItem datData.Recordset("Amount")
datData.Recordset.FindNext (strQueryString)
Loop
End Sub
Private Sub lstData_Click()
' When a selection in the list is seelcted I want to fill in the fields so I can see it.
datAcctNum.Recordset.FindFirst "Amount = " & lstAccounts.List(lstAccounts.ListIndex) & ""
End Sub
I am not sure how to go about getting the results I need.