Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    WAVP375 is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171

    +Selecting a table to query


    in a database of 'Events' I have a table of event name 'TblEventNames' that I update each time I create a new event table. Update and reports are required from any one of the vents at user chosen times. I am attempting to show all event names in a list box the select the event that I want to run a report on. My thought is to create a query that will run against whichever table I choose from the list box. This way one report bound to the query is all that is required. Or maybe there is a way to make a variable bind in the report itself.

    Any thoughts would be appreciated.

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,849
    I am not sure of what you are asking, but this link may be helpful.

    Good luck.

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,842
    each time I create a new event table
    why are you creating a new table for a new event? You should have one table, with an event FK linked back to the event PK in your EventNames table. Then your report would be easy

  4. #4
    WAVP375 is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171
    What is an event FK?

  5. #5
    WAVP375 is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171
    Sorry for my ignorance. I follow the use of the primary key in the Event Name table but I will still need a query to select the records for the group of names associated with the event name behind the primary key. How do I make that query selectable.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Agree with Ajax, should not create a table for each event. One table and the quandary of how to select particular event table is eliminated.

    Use a form for user to select filter criteria. Apply filter to a form or report.

    Review: http://allenbrowne.com/ser-62.html
    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
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,842
    PK=Primary Key
    FK=Foreign or Family Key

    There is a one to many relationship between a PK and FK's in the related tables

  8. #8
    WAVP375 is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171
    I see your suggestion is a good one. TblEventDownLoad contains names that have been down loaded from an excel spreadsheet. I have created a query QappVolNamesTable to append the names to the existing events I am attempting to force an event number in to a field in the table to differentiate this event from others in the table. When I execute the query I get an error 'Duplicate Output Alias 'Expr1". The query expression is as follows:

    Expr1:[Forms]![FrmEventDownLoad]![EventNumber], append to: EventNumber

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    How is the EventNumber created? Why would you need to run an UPDATE query? If you want to provide db for analysis, follow instructions at bottom of my post.
    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
    WAVP375 is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171
    Sorry, not an update query but an append query where I add the new event to the table. The event number is applied in the append query. This is all working fine now. Thanks this approach should be much better in the long run.

    I am now have a problem with an update form where I want to populate a list box with persons from only one event where the event number is contained in a text box on the form. The code I am using is

    Dim FilterSource As String
    FilterSource = "Select[TblVolNames].[EventNumber],
    [TblVolNames].[Badge],
    [TblVolNames].
    [LastName],
    [TblVolNames].
    [FirstName],
    [TblVolNames].
    [Volunteers],
    [TblVolNames].
    [Guests],
    [TblVolNames].[
    Paid],
    From[TblVolNames]; Where [TblVolName[.[EventNumber] = Me.MyEvent"
    Me.LstNames.RowSource = FilterSource
    Me.LstNames.Requery

    Where LstNames is the list box
    Where MyEvent is the Textbox with the event number

    When I execute the listbox goes empty



  11. #11
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,700
    Syntax problems:
    Code:
    Paid] 
    From [TblVolNames]; Where [TblVolName[.[EventNumber] =" & Me.MyEvent

    Delete the comma after Paid], but leave a space
    Add a space after FROM
    Delete the semicolon after [tblVolNames] but leave the space
    Edit like the red

  12. #12
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,121
    Further correction

    Code:
    Paid] 
    FROM [TblVolNames] WHERE [TblVolName].[EventNumber] =" & Me.MyEvent
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Also need a space after SELECT:

    FilterSource = "SELECT EventNumber, Badge, LastName, FirstName, Volunteers, Guests, Paid FROM TblVolNames WHERE EventNumber = " & Me.MyEvent & ";"

    Assumes EventNumber is a number type.

    But really don't need to set the listbox RowSource with code. Put the SQL statement in the RowSource property and then just run the Requery method in code.
    SELECT EventNumber, Badge, LastName, FirstName, Volunteers, Guests, Paid FROM TblVolNames WHERE EventNumber = [MyEvent];
    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
    WAVP375 is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171
    Thanks guys, getting the punctuation correct is the toughest. That working populates the list box with only the records for the selected event. However when I choose one of the items in the listbox the first item in the listbox is all that displays on the form.

  15. #15
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    This is called cascading (dependent) combo or list box. They won't work nice on continuous or datasheet form if the RowSource is a lookup with alias. A frequently discussed topic.
    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.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Selecting a specific cell in a table
    By roaftech in forum Programming
    Replies: 5
    Last Post: 09-18-2017, 02:32 AM
  2. Replies: 5
    Last Post: 03-22-2016, 04:06 PM
  3. Selecting row sections from a table
    By dmol in forum Access
    Replies: 3
    Last Post: 02-24-2011, 01:21 PM
  4. query- selecting a table...
    By giladweil in forum Access
    Replies: 5
    Last Post: 02-01-2011, 05:26 AM
  5. Selecting the last value of the table and show
    By dada in forum Programming
    Replies: 3
    Last Post: 08-21-2010, 01:14 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