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

    Unanswered: Can't get the right SQL syntax

    I made countless references with SQL books, and Access still reports some syntax errors, or "missing parameter"... Hope some of you to help.
    -----
    sqlText1 = "SELECT ProgramId, CourseId FROM ProgramDetails WHERE ProgramId = Me.ProgramId;"

    sqlText2 = "SELECT StudentId, ProgramId FROM Registrations WHERE ProgramId > 0 AND StudentId = Me.StudentId;"
    -----------

    Also could someone explain me why some of the pros suggest to use "SELECT Table.Field1, Table.Field2 FROM Table" instead of
    "SELECT Field1, Field2 FROM Table". At least the SQL books I looked at, this is not a requirement.

    Thanks for your help
    Jazz

  2. #2
    Join Date
    May 2002
    Location
    Atlanta, GA
    Posts
    117
    Hey Jazz,

    Two things, one - instead of using Me.YourField, try using the better Forms!YourFormName!StudentID. That way you can use the code from anywhere. Second - try adding something like this to your statements:

    SELECT field FROM table WHERE(field = " & Forms!YourForm!Field & ");

    This is for Integer data types. If its text, try this:

    SELECT field FROM table WHERE(field = """ & Forms!YourForm!Field & """);

    Let me know if this helps,
    Kal

  3. #3
    Join Date
    Feb 2003
    Posts
    65
    Thanks Cal,

    That is a good advice.

    While waiting I think I got the syntax. I use now:

    sqlText1 = "SELECT ProgramId, CourseId FROM ProgramDetails WHERE CourseId =" & Me.CourseId

    sqlText2 = "SELECT StudentId, ProgramId FROM Registrations WHERE NOT ProgramId Is Null AND StudentId =" & Me.StudentId

    and Access doesn't report any errs.

    However I run into more troubles. Please see my other post.

    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
  •