Results 1 to 4 of 4
  1. #1
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    754

    Select Statement Syntax Error? Cant Find Error?

    Hi all,
    I am getting an error with this select statement in a Combo RowSource and can someone please tell me what i am doing wrong?

    Code:
    SELECT AddressID, LocationTypeID, AddressType, Preferred FROM CompanyAddressByLocationQry WHERE LocationTypeID= & Me.CboLocation ORDER BY Preferred;


  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    It would help to see the context, but presumably you're building an SQ string. You don't stop the string before the "&", and you don't continue it after the form reference. If that's not in VBA code, you can't refer to the form like that.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    looks like this is what is referred to as a cascading combo - user having selected a location, you then want to limit the number of addresses to that location

    if this is the case try

    Code:
    SELECT AddressID, LocationTypeID, AddressType, Preferred FROM CompanyAddressByLocationQry WHERE LocationTypeID= [CboLocation] ORDER BY Preferred;
    note that you will need to requery the combo for which this is the rowsource in the afterupdate event of cboLocations to trigger a refresh of the data

  4. #4
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    754
    Thank you
    This worked great

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 07-15-2019, 10:20 AM
  2. Replies: 4
    Last Post: 03-26-2019, 02:40 PM
  3. Replies: 1
    Last Post: 09-22-2014, 08:54 AM
  4. Error 3144: Syntax error in UPDATE statement??
    By Paintballlovr in forum Programming
    Replies: 7
    Last Post: 03-26-2014, 12:53 PM
  5. Compile Error: Syntax Error in DoCmd.RunSQL Statement
    By Evilferret in forum Programming
    Replies: 1
    Last Post: 08-27-2012, 12:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums