rickb
Member
I have a listbox which displays a list of names filtered by alphabet (The filtering is done via the text property of a textbox). Heres the problem: The filtered list is displayed in a listbox, and the relevant info for the selected name appears in a series of textboxes. When I select a different name, however, the data in the textboxes doesnt change. I wouldve thought that the solution might have something to do with an listbox.selecteditem event, but Im so lost Im not even sure about that. Heres the code for the sub that is triggered when, for example, the "A" button is clicked (thanks again to Jon(jfackler) for the code above the texbox binding):
Can anyone point me in the right direction for a solution? Thanks in advance.
Rick
Code:
Public Sub LoadList()
Dim daUserList As New OleDbDataAdapter(_
"SELECT * FROM tblAS400Users WHERE LastName LIKE " & _
txtPick.Text & "% ORDER BY LastName,FirstName", oledbconn)
Dim strName As String
Dim oUserList As Object
Dim oCurr As Object
Dim dsUserList As New DataSet()
Dim BldgNum As String
Create the calculated column
Try
daUserList.Fill(dsUserList, "tblAS400Users")
create a new column
Dim dcName As DataColumn
dcName = New DataColumn("Name")
dcName.DataType = System.Type.GetType("System.String")
dcName.Expression = "LastName + , + FirstName"
Add the calculated column
dsUserList.Tables("tblAS400Users").Columns.Add(dcName)
Bind to the listbox
With Me.lstUsers
.DataSource = dsUserList.Tables("tblAS400Users")
.DisplayMember = "Name"
End With
Catch ex As Exception
MsgBox(ex.ToString)
Exit Sub
End Try
Enable the Delete and Edit Button
cmdDelete.Enabled = True
cmdEdit.Enabled = True
Me.txtBldgNum.DataBindings.Add("text", dsUserList, "tblAS400Users.LOC")
Me.txtBldg.DataBindings.Add("text", dsUserList, "tblAS400Users.Building")
Me.txtUserName.DataBindings.Add("text", dsUserList, "tblAS400Users.Name")
Me.txtDeviceID.DataBindings.Add("text", dsUserList, "tblAS400Users.DeviceID")
Me.txtUserProfile.DataBindings.Add("text", dsUserList, "tblAS400Users.UserProfile")
Me.txtLastName.DataBindings.Add("text", dsUserList, "tblAS400Users.LastName")
Me.txtFirstName.DataBindings.Add("text", dsUserList, "tblAS400Users.FirstName")
For Each oCurr In Me.Controls
If TypeOf oCurr Is TextBox Then
oCurr.databindings.clear()
End If
Next
If lstUsers.Items.Count = 0 Then
For Each oCurr In Me.Controls
If TypeOf oCurr Is TextBox Then
oCurr.text = ""
End If
Next
End If
BldgNum = Me.txtBldgNum.Text
Select Case BldgNum
Case 59 To 81
Me.txtLAN.Visible = True
Me.lblLAN.Visible = True
Me.txtLAN.DataBindings.Add("text", dsUserList, "tblAS400Users.LANAddress")
Case Else
Me.txtLAN.Visible = False
Me.lblLAN.Visible = False
Exit Sub
End Select
End Sub
Can anyone point me in the right direction for a solution? Thanks in advance.
Rick
Last edited by a moderator: