Results 1 to 9 of 9
  1. #1
    nanp is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Dec 2024
    Posts
    4

    Question Rowsource Select * not returning all fields

    I have a form with a search results list box and the search parameters are working great, but it's not returning all fields from the table. I used Select * so it should return all fields from the table I thought.

    It's based on a single table. When I open the table itself, it has the field I'm looking for, but when I run the search on the form, it doesn't have the field.

    lstSearchResults.RowSource = "SELECT * FROM vw_srch_NameByAddressInfo WHERE LastName LIKE '%" & sSearchText & "%' OR FirstName LIKE '%" & sSearchText & "%' OR Chapter LIKE '%" & sSearchText & "%' OR Company LIKE '%" & sSearchText & "%' OR City LIKE '%" & sSearchText & "%' OR State LIKE '%" & sSearchText & "%' OR Zip LIKE '%" & sSearchText & "%' OR Address LIKE '%" & sSearchText & "%' ORDER BY LastName,FirstName,MiddleName,Title,Chapter"

    Any ideas where else I can look that's preventing the one field I really need from populating in the list box?

    TIA

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,573
    Is the field count correct?
    I would expect the query to be correct. Have you even looked at that?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    nanp is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Dec 2024
    Posts
    4
    Oh, I don't know. Forgive my stupidity, I don't know how to look for that. I'm still very new at all of this.

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,573
    Debug.print that sql when it has been populated with form values. Or just a simple select *.
    Run the query string in the query sql window when the form is open with valid values.
    Any control like combo or listbox needs the field count to match the number of fields in the source, if you want to make them available.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    Minty is online now VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,159
    I would assume from the name that vw_srch_NameByAddressInfo is a linked SQL server view rather than a raw table?
    Out of interest what is the name of the field that is missing?


    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  6. #6
    nanp is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Dec 2024
    Posts
    4
    Thank you. I will give that a go.

  7. #7
    nanp is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Dec 2024
    Posts
    4
    yes, it's a linked SQL server view. The field missing is NameChapterStatusID

  8. #8
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,573
    Actually called ColumnCount. Now back on my PC.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    You may need to refresh the view:

    https://www.mssqltips.com/sqlservert...-are-modified/
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Open Rowsource as a Select Query
    By MykelDL in forum Programming
    Replies: 8
    Last Post: 01-07-2024, 02:42 PM
  2. Replies: 1
    Last Post: 08-21-2017, 03:07 PM
  3. Replies: 3
    Last Post: 03-17-2017, 02:14 AM
  4. Replies: 14
    Last Post: 05-27-2015, 11:37 AM
  5. Replies: 6
    Last Post: 09-30-2010, 11:12 AM

Tags for this Thread

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