Results 1 to 2 of 2
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    wrong syntax (Access 2000)

    Wrong syntax with " = City & "



    Can somebody explain me what is wrong with my function below? It doesnt work even though i followed the recommendations
    for this method.On the other hand,if i write

    " WHERE customers.afid = 2

    Then it works.

    May i ask for help?

    Public Function Customers()
    Dim City As Long
    City = Forms![FOrderInformation]![office] - 1

    Dim strBas As String
    strBas = " SELECT customers.Customerid, customers.CompanyName, customers.afid " & _
    " FROM affiliates INNER JOIN customers ON affiliates.afid = customers.afid " & _
    " WHERE customers.afid" & city & " ORDER BY customers.CompanyName;"


    Forms![FOrderInformation]![Customerid].RowSource = strBas
    End Function

  2. #2
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: wrong syntax (Access 2000)

    <hr>' WHERE customers.afid" & city & " ORDER BY customers.CompanyName;"<hr>
    You are missing the = sign in the line above

    " WHERE customers.afid = " & city & " ORDER BY customers.CompanyName;"

    Assuming that city is a number and not text.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

Posting Permissions

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