I have a program, for an opticians...

I need to make 4 working screens.. I can order spectacles, this works...

I choose a customer from CustomerTable
Adds a record to a SpecSalesTable, and an auto key is allocated to each sale. (SpecSalesID)


In another screen, I need to display all the frames which have been ordered.
These frames are in the FrameID - SpecSalesTable

When I click the frameID in the listbox, I need the SpecSalesID to be loaded corrosponding to the frameID... which is in a different table, so Inner join is used, but none of mine will work at the moment...

Some code:
RARRR Code:
  1. Dim ConnectionString As String
  2.         Dim SQLString As String
  3.         Dim cmd As System.Data.OleDb.OleDbCommand
  4.         Dim conn As System.Data.OleDb.OleDbConnection
  5.         Dim dr As System.Data.OleDb.OleDbDataReader
  6.         ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data "
  7.         ConnectionString += "Source=" & "Opticians.accdb "
  8.         conn = New System.Data.OleDb.OleDbConnection(ConnectionString)
  9.         TextBox1.Text = FramesListBox.Text
  10.         SQLString = "SELECT * FROM SpecSalesTable "
  11.         SQLString += "INNER JOIN CustomerTable ON SpecSalesTable.CustomerID = CustomerTable.CustomerID "
  12.         SQLString += "Where '" & TextBox1.Text & "'"
  13.         SQLString += "= SpecSalesTable.FrameID"
  14.  
  15.         'frame id = stock id
  16.         ' spec sales table
  17.         ' stock table
  18.         Try
  19.             conn.Open()
  20.             If ConnectionState.Open.ToString = "Open" Then
  21.                 cmd = New System.Data.OleDb.OleDbCommand(SQLString, conn)
  22.                 dr = cmd.ExecuteReader()
  23.                 If dr.HasRows Then
  24.                     dr.Read()
  25.                     If Not IsDBNull(dr.Item("FrameID")) Then
  26.                         TextBox1.Text = dr.Item("FrameID").ToString
  27.                     End If
  28.                     If Not IsDBNull(dr.Item("CustomerID")) Then
  29.                         TextBox2.Text = dr.Item("CustomerID").ToString
  30.                     End If
  31.                     If Not IsDBNull(dr.Item("Surname")) Then
  32.                         TextBox3.Text = dr.Item("Surname").ToString
  33.                     End If
  34.                     If Not IsDBNull(dr.Item("Firstname")) Then
  35.                         TextBox3.Text = dr.Item("Firstname").ToString
  36.                     End If
  37.  
  38.                 End If
  39.             End If
  40.         Catch ex As Exception
  41.         End Try