sql syntax comparing fields

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • stupot1987
    New Member
    • Jun 2007
    • 8

    sql syntax comparing fields

    hey im new to this site but found it has helped me in the past with other similar problems. i want to be able to compare 2 fields in my sql my code is as follows:

    Code:
     
    Private Sub Command1_Click()
    Exit Sub
    Adodc1.RecordSource = "SELECT Stock.[Product Code], Stock.Description, Stock.[Quantity in Stock], Stock.[Re Order Level] FROM Stock; 
    [B]WHERE Stock.[Quantity in Stock]) < Stock.[Re Order Level];"[/B]
    Adodc1.Recordset.Requery
    Adodc1.Refresh
    DataGrid1.Refresh
    End Sub
    The bold part is where i appear to be having problems. am i missing quotations or brackets or something?
    thnx in advance
  • jasperz01
    New Member
    • Jun 2007
    • 20

    #2
    Originally posted by stupot1987
    hey im new to this site but found it has helped me in the past with other similar problems. i want to be able to compare 2 fields in my sql my code is as follows:

    Code:
     
    Private Sub Command1_Click()
    Exit Sub
    Adodc1.RecordSource = "SELECT Stock.[Product Code], Stock.Description, Stock.[Quantity in Stock], Stock.[Re Order Level] FROM Stock; 
    [B]WHERE Stock.[Quantity in Stock]) < Stock.[Re Order Level];"[/B]
    Adodc1.Recordset.Requery
    Adodc1.Refresh
    DataGrid1.Refresh
    End Sub
    The bold part is where i appear to be having problems. am i missing quotations or brackets or something?
    thnx in advance
    Lose the semicolon ( ; ) at the end of your FROM Stock; but leave it at the end of your sentence.

    like this:
    Code:
    Adodc1.RecordSource = "SELECT Stock.[Product Code], Stock.Description, Stock.[Quantity in Stock], Stock.[Re Order Level] FROM Stock WHERE Stock.[Quantity in Stock]) < Stock.[Re Order Level];"
    Jasper

    Comment

    • stupot1987
      New Member
      • Jun 2007
      • 8

      #3
      cheers, but it still aint doin nothing! datagrid doesnt show the output from the query. :(

      Comment

      • jasperz01
        New Member
        • Jun 2007
        • 20

        #4
        Originally posted by stupot1987
        cheers, but it still aint doin nothing! datagrid doesnt show the output from the query. :(
        Ok, try using Access Query Analyzer to troubleshoot the query I'd say:

        http://www.sliver.com/dotnet/AccessQueryAnal yzer/

        Good luck,

        Jasper

        Comment

        • stupot1987
          New Member
          • Jun 2007
          • 8

          #5
          guys im stil struggling on this one i feel its somethin to do with quotation marks!! took me ages to find out how to use them in a text field! any suggestions?

          Comment

          Working...