Results 1 to 5 of 5
  1. #1
    Rev12 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2016
    Posts
    11

    How to display fieldnames of a report to another listbox in a form?

    Dear Everyone,
    I have two listboxes


    1. Name : LstReports = display all my reports = Row Source : SELECT DISTINCTROW [Name] FROM MSysObjects WHERE [Type] = -32764 ORDER BY [Name];
    2. Name : lstRptFldNames = should display all the fields of a selected Reports = Row Source : I don't know how to do it??

    My Reports = Record Source are from my Tables "qryAssetsGroup"
    I want to display all my fieldnames to my listbox 2 after a select from from my listbox 1?
    Please anyone is kind to help me figure out the code or a way around to make it happen?

    Is it possible to display to my 2 listbox the Field Names from a REPORT? Or it is necessary to have it in query??

    I was no luck to find any related threads. Any help is appreciated.

    Thanks again,
    Rev12
    Last edited by Rev12; 07-13-2018 at 01:33 AM.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    everything you want in the report , put it in the query.
    then make the report from the query. (the instant report button will do it for you)

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,915
    Why do you need to list fields in a listbox? What are you really trying to accomplish? Unless you have a query object for each report that can also be used as the RowSource of listbox (RowSourceType set to FieldList), the code would likely be very complicated.

    Duplicate question https://www.accessforums.net/showthread.php?t=72888
    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.

  4. #4
    Rev12 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2016
    Posts
    11
    [QUOTE=June7;403174]Why do you need to list fields in a listbox? What are you really trying to accomplish? Unless you have a query object for each report that can also be used as the RowSource of listbox (RowSourceType set to FieldList), the code would likely be very complicated.

    -- instead of creating many queries I will just create 1 queries and export base on our department manager needs of which field they want to use or view after export.

    please any help is much appreciated.

    thanks in advance,
    Rev12

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,915
    How do you imagine 1 query will accomplish that? Fields in a query object cannot be dynamic - they are either in the query or they aren't.

    If you want to allow users to select fields for export, this will require VBA manipulating QueryDefs collection to modify/save query object structure. I do not recommend implementing code that routinely modifies db design. I have done something like this only once and it was to modify filter criteria of query, not allow variable field selection.

    Another approach may be to save data to a 'temp' table (table is permanent, records are temporary). Again, code will be complicated.

    Regardless of the approach, the coding is likely well beyond the experience level of a novice and more complicated than I am willing to deal with. Do research and when you have code with specific issue, post question.
    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.

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

Similar Threads

  1. Transfer form listbox data to Report listbox.
    By onlylonely in forum Reports
    Replies: 6
    Last Post: 10-08-2017, 07:14 PM
  2. Replies: 2
    Last Post: 05-25-2017, 12:48 PM
  3. Replies: 8
    Last Post: 11-11-2013, 08:39 PM
  4. Replies: 14
    Last Post: 12-26-2011, 07:32 PM
  5. Replies: 3
    Last Post: 02-01-2011, 09:47 AM

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