Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2003
    Posts
    65

    Unanswered: Help with sql syntax

    The following sql statement gives a syntax err. If i copy the code and put it in a query designer, it works.

    -----
    sqlCompleted = "SELECT Marks.StudentId, Marks.CourseId, Marks.CourseCompleted" _
    & "FROM Students INNER JOIN Marks ON Students.StudentId = Marks.StudentId" _
    & "WHERE Marks.CourseCompleted = Yes And Marks.StudentId = " & Me.StudentId

    Set rs2 = db.OpenRecordset(sqlCompleted)
    -------------------

    Hope some of you to help.
    Jazz

  2. #2
    Join Date
    Oct 2002
    Location
    Greensboro, NC
    Posts
    50

    Re: Help with sql syntax

    try typing it like this


    sqlCompleted = "SELECT Marks.StudentId, Marks.CourseId, Marks.CourseCompleted FROM Students INNER JOIN Marks ON Students.StudentId = Marks.StudentId WHERE Marks.CourseCompleted=Yes And Marks.StudentId=" & Me.StudentId

    Set db = CurrentDb()
    Set rs2 = db.OpenRecordset(sqlCompleted)


    tina
    Originally posted by jazz novice
    The following sql statement gives a syntax err. If i copy the code and put it in a query designer, it works.

    -----
    sqlCompleted = "SELECT Marks.StudentId, Marks.CourseId, Marks.CourseCompleted" _
    & "FROM Students INNER JOIN Marks ON Students.StudentId = Marks.StudentId" _
    & "WHERE Marks.CourseCompleted = Yes And Marks.StudentId = " & Me.StudentId

    Set rs2 = db.OpenRecordset(sqlCompleted)
    -------------------

    Hope some of you to help.
    Jazz

  3. #3
    Join Date
    Feb 2003
    Posts
    65

    Re: Help with sql syntax

    Originally posted by tjacobs
    try typing it like this


    sqlCompleted = "SELECT Marks.StudentId, Marks.CourseId, Marks.CourseCompleted FROM Students INNER JOIN Marks ON Students.StudentId = Marks.StudentId WHERE Marks.CourseCompleted=Yes And Marks.StudentId=" & Me.StudentId

    Set db = CurrentDb()
    Set rs2 = db.OpenRecordset(sqlCompleted)


    tina
    Thanks Tina, it works. You have a magic hand I guess...

    Now other problems are over my head. If you wish, please check my questions "Help with Forms".

    Thanks again.
    Jazz

Posting Permissions

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