I'm selecting a customer from a listbox of surnames...

I need to address to display, and the date arrived back...

Can't get anything to go into the textboxes, if dr.hasrows is showing up as none I think... not sure how to go about remedey"ing" it though...

Listbox Code:
  1. Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
  2.         Dim ConnectionString As String
  3.         Dim SQLString As String
  4.         Dim cmd As System.Data.OleDb.OleDbCommand
  5.         Dim conn As System.Data.OleDb.OleDbConnection
  6.         Dim dr As System.Data.OleDb.OleDbDataReader
  7.         ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data "
  8.         ConnectionString += "Source=" & "Opticians.accdb "
  9.         conn = New System.Data.OleDb.OleDbConnection(ConnectionString)
  10.         AddressTextBox.Text = ListBox1.Text 'Gives the AddressTextBox the value that we click in the ListBox
  11.         SQLString = "SELECT * FROM CustomerTable " ' Selects all from CustomerTable
  12.         SQLString += "INNER JOIN SpectacleSalesTable ON CustomerTable.CustomerID = SpectacleSalesTable.CustomerID " 'Bring EyeTestTable in, using the records where the CustomerID matches up in both tables
  13.         SQLString += "Where '" & AddressTextBox.Text & "'" 'If the value that we clicked in the listbox, matches the surname it will try to connect
  14.         SQLString += "= Surname"
  15.         Try
  16.             conn.Open()
  17.             If ConnectionState.Open.ToString = "Open" Then
  18.                 cmd = New System.Data.OleDb.OleDbCommand(SQLString, conn)
  19.                 dr = cmd.ExecuteReader()
  20.                 If dr.HasRows Then
  21.                     dr.Read()
  22.                     If Not IsDBNull(dr.Item("SpecSalesTable.FrameID")) Then
  23.                         DepositTextBox.Text = dr.Item("SpecSalesTable.FrameID").ToString 'Adds the CustomerID to the CustomerIDTextBox
  24.                     End If
  25.                     If Not IsDBNull(dr.Item("SpecSalesTable.DateReceived")) Then
  26.                         DateReceivedTextBox.Text = dr.Item("SpecSalesTable.DateReceived").ToString 'Adds the EyeTestID to the EyeTestIDTextBox
  27.                     End If
  28.                     If Not IsDBNull(dr.Item("CustomerTable.Street")) Then
  29.                         AddressTextBox.Text = dr.Item("CustomerTable.Street").ToString 'Adds the Street to the AddressTextBox
  30.                     End If
  31.                     If Not IsDBNull(dr.Item("CustomerTable.Town")) Then
  32.                         Address2TextBox.Text = dr.Item("CustomerTable.Town").ToString 'Adds the Town to the Address2TextBox
  33.                     End If
  34.                     If Not IsDBNull(dr.Item("CustomerTable.County")) Then
  35.                         Address3TextBox.Text = dr.Item("CustomerTable.County").ToString 'Adds the County to the Address3TextBox
  36.                     End If
  37.                 End If
  38.             End If
  39.         Catch ex As Exception
  40.         End Try
  41.     End Sub