Results 1 to 15 of 15
  1. #1
    merlin777 is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Sep 2011
    Posts
    117

    wrong column order when displaying query in a list box

    I am displaying a query on a form by putting it in a list box. This is perfect for my needs because it's a simple, tidy look and I don't need to change any data using it.



    However, although the query displays correctly in datasheet view, in the list box the columns are in the wrong order.

    Also, where the query displays a linked value rather than the id number for a field, the list box just displays the id number (for instance, one of the fields in my main table is 'therapistid' and is a number that links to the 'tbltherapist' but actually displays a therapist name and so does the query whereas the list box shows the number).

    any idea what I'm doing wrong?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Advise not to use lookups in table http://access.mvps.org/access/lookupfields.htm

    If you want to show the descriptive text in listbox, its RowSource will have to be a query that joins tables.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    I think that the issue may be in the properties for the list box. Here is a link to some tutorials. Scroll down to the section for combo boxes. It uses the same principle for the list boxes.

    http://www.datapigtechnologies.com/AccessMain.htm

  4. #4
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529

  5. #5
    merlin777 is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Sep 2011
    Posts
    117
    wow - these tutorials are fantastic.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Use an SQL statement in the listbox or combobox RowSource to explicitly specify column order.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    merlin777 is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Sep 2011
    Posts
    117
    before you make the order explicit, where does it derive the order from by default?

  8. #8
    merlin777 is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Sep 2011
    Posts
    117
    Quote Originally Posted by June7 View Post
    Advise not to use lookups in table http://access.mvps.org/access/lookupfields.htm

    If you want to show the descriptive text in listbox, its RowSource will have to be a query that joins tables.
    Could you bear to give me an example please?

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Just build a query that joins the data table with the lookup source table. You can open the query builder by clicking the ellipsis (...) in the RowSource property.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    merlin777 is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Sep 2011
    Posts
    117
    by 'join' do you mean use any expression in a query field that contains fields from the 2 tables (e.g. concatenate the 2 fields) or is there a specific way to join them?

  11. #11
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Join tables by linking on the key fields. This is not concatenation. This is basic Access functionality using the query builder.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #12
    merlin777 is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Sep 2011
    Posts
    117
    excuse my clumsy question. I used concatenation as an example of a function to put in the query that uses both tables - didn't mean concatenation in the sense of 'joining' tables.

    Specifically where do I link the key fields, please?

  13. #13
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Did you search Access Help?

    http://www.opengatesw.net/ms-access-...stent_font_use

    Create the link line by click on one field in a table and drag to field in other table.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  14. #14
    merlin777 is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Sep 2011
    Posts
    117
    Thanks for the link. I do use help but sometimes it's trick if you don't use the right key words.

  15. #15
    merlin777 is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Sep 2011
    Posts
    117
    I just wanted to say thanks to all who have responded over th last day or two. I've spent most of the day really playing and hammering away and although I will still have questions the mists are starting to clear. Thanks!

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

Similar Threads

  1. Replies: 5
    Last Post: 08-11-2014, 03:08 PM
  2. Query from list box displaying incorrect values.
    By adammitchell23 in forum Queries
    Replies: 3
    Last Post: 11-28-2013, 12:54 PM
  3. vba code running in wrong order??
    By Paintballlovr in forum Programming
    Replies: 3
    Last Post: 08-30-2013, 03:53 PM
  4. Form with Subreport Displaying Wrong
    By claysea in forum Forms
    Replies: 3
    Last Post: 02-14-2012, 03:25 PM
  5. Replies: 3
    Last Post: 09-28-2011, 04:29 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