Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2014
    Posts
    2

    Unhappy Unanswered: Need help with inner join syntax

    I'm trying to do an inner join but I'm getting an inner join syntax error. Please help me. Here's my code:

    Dim sql as string

    sql = "SELECT Sum([tblAccounts.AmountPaid]) AS Expr1, Count([tblAccounts.OR]) AS Expr2 " _
    + "FROM (tblFEES INNER JOIN tblStudents ON tblFees.FeeCode = tblStudednts.FeeCode)" _
    + " INNER JOIN tblAccounts ON tblStudents.StudentName = tblAccounts.StudentName" _
    + " WHERE (((tblStudents.StudentName) ='" + Me.cboStudent.Text + "'))"

    cmd = New OleDb.OleDbCommand(sql, con)
    dr = cmd.ExecuteReader

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    1. Type mismatch, change:
    Code:
    + "FROM (tblFEES INNER JOIN tblStudents ON tblFees.FeeCode = tblStudednts.FeeCode)" _
    to:
    Code:
    + "FROM (tblFEES INNER JOIN tblStudents ON tblFees.FeeCode = tblStudents.FeeCode)" _
    2. The Text property is only available when the control has the focus, change:
    Code:
    + " WHERE (((tblStudents.StudentName) ='" + Me.cboStudent.Text + "'))"
    to:
    Code:
    + " WHERE (((tblStudents.StudentName) ='" + Me.cboStudent.Value + "'))"
    Have a nice day!

  3. #3
    Join Date
    Feb 2014
    Posts
    2
    Thanks!

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You're welcome!
    Have a nice day!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •