ok Code:
  1. Public Class ReceiptSpectacles
  2.  
  3.     Private Sub ReceiptSpectacles_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  4.         DisplayList(5) 'LOADS DISPLAYLIST METHOD
  5.     End Sub
  6.  
  7.     Private Sub DisplayList(ByVal CusRef As Integer)
  8.         Dim ConnectionString As String
  9.         Dim SQLString As String
  10.         Dim TitleString As String
  11.         Dim conn As System.Data.OleDb.OleDbConnection
  12.         Dim dr As System.Data.OleDb.OleDbDataReader
  13.         Dim cmd As System.Data.OleDb.OleDbCommand
  14.         ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;data "
  15.         ConnectionString += "Source=" & "Opticians.accdb "
  16.         conn = New System.Data.OleDb.OleDbConnection(ConnectionString)
  17.         SQLString = "SELECT * FROM SpecSalesTable" 'SELECTS ALL INFORMATION
  18.         Try                                     '    FROM DATABASE
  19.             conn.Open()
  20.             If ConnectionState.Open Then
  21.                 cmd = New System.Data.OleDb.OleDbCommand(SQLString, conn)
  22.                 dr = cmd.ExecuteReader()
  23.                 If dr.HasRows Then
  24.                     FramesListBox.Items.Clear()
  25.                     While dr.Read
  26.                         If Not IsDBNull(dr.Item("FrameID")) Then  'INSERTS INFORMATION INTO
  27.                             TitleString = dr.Item("FrameID")      '       LISTBOX
  28.                             FramesListBox.Items.Add(TitleString)
  29.                         End If
  30.                     End While
  31.                 End If
  32.                 dr.Close()
  33.             End If
  34.         Catch
  35.             MessageBox.Show("Error accessing database")     'IF ERROR ENCOUNTERED SHOWS MESSAGE
  36.         End Try
  37.         conn.Close()
  38.     End Sub
  39.  
  40.     Private Sub FramesListBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FramesListBox.SelectedIndexChanged
  41.         Dim ConnectionString As String
  42.         Dim SQLString As String
  43.         Dim cmd As System.Data.OleDb.OleDbCommand
  44.         Dim conn As System.Data.OleDb.OleDbConnection
  45.         Dim dr As System.Data.OleDb.OleDbDataReader
  46.         ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data "
  47.         ConnectionString += "Source=" & "Opticians.accdb "
  48.         conn = New System.Data.OleDb.OleDbConnection(ConnectionString)
  49.         TextBox1.Text = FramesListBox.Text
  50.         SQLString = "SELECT * FROM SpecSalesTable "
  51.         SQLString += "INNER JOIN CustomerTable ON SpecSalesTable.CustomerID = CustomerTable.CustomerID "
  52.         SQLString += "Where '" & TextBox1.Text & "'"
  53.         SQLString += "= FrameID"
  54.         Try
  55.             conn.Open()
  56.             If ConnectionState.Open.ToString = "Open" Then
  57.                 cmd = New System.Data.OleDb.OleDbCommand(SQLString, conn)
  58.                 dr = cmd.ExecuteReader()
  59.                 [I]If dr.HasRows Then[/I]
  60.                     dr.Read()
  61.                     If Not IsDBNull(dr.Item("FrameID")) Then
  62.                         TextBox1.Text = dr.Item("FrameID").ToString
  63.                     End If
  64.                     If Not IsDBNull(dr.Item("CustomerID")) Then
  65.                         TextBox2.Text = dr.Item("CustomerID").ToString
  66.                     End If
  67.                     If Not IsDBNull(dr.Item("Surname")) Then
  68.                         TextBox3.Text = dr.Item("Surname").ToString
  69.                     End If
  70.                     If Not IsDBNull(dr.Item("Firstname")) Then
  71.                         TextBox3.Text = dr.Item("Firstname").ToString
  72.                     End If
  73.  
  74.                 End If
  75.             End If
  76.         Catch ex As Exception
  77.         End Try
  78.     End Sub


Right, there's my code...

A listbox, 3 text boxes.

The listbox should display the FrameID which is located in the SpecSalesTable

Then I want, the surname, firstname from the Customer table to be displayed, provided the customer table. customerID = specsalestable.customerID

Any ideas why this isn't working?

I italic'd a part
"If dr.HasRows Then"

Thats showing up as not having rows, so it's not even trying to do the add to textbox part...


Thanks