Results 1 to 7 of 7
  1. #1
    WAVP375 is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171

    Programmatically change 'Record Source' in a report or form

    I am creating a DB of events. There will be multiple eventsat a given time. The attendees to the event will be selected in another DB andexported to excel. The excel spreadsheet will be imported to the new DB andwill create a table with all the intended attendees. Each event will have anexact table design with specific attendees. The table will contain ‘EventId’, ‘EventName’, ‘AttendeeId’, ‘AttendeeName’ and ‘NbrAttending’.As required each will need to be updated or a roster printed. After the eventis over the table will need to be deleted. I’m thinking a form with a list boxof events from which to select the one to be dealt with. Also a button toselect which of the update, delete or print options to be taken.
    With a single form for each option, I am a t a loss as tohow to change the record source based upon the selection made in the list box.
    Or is there a better way to address this challenge.


    Any thoughts will behelpful, thanks.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,522
    in a form, have a combo box, 2 cols: CAPTION, QRY
    users see the caption name: CAPTION.
    but combo is bound to hidden column: QRY
    user picks ATTENDEES, the query is qsAttendees,

    the afterupdate event assignes the query:
    Code:
    sub cboBox_Afterupdate()
    If IsNull(cboBox) Then
      me.RecordSource= "qsAll"
    Else
      me.RecordSource = cboBox
    End If
    end sub

  3. #3
    WAVP375 is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171
    I'm having trouble with the logic. My combo box will contain 'Event Name' and 'Table Name' sourced from an Event Table.
    When I select an event how do I get that table name into the report or update form objects?

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,522
    Make it easy,
    when you pick the Event, have another column in the combo for the report for that event,
    open that report for that event.

  5. #5
    WAVP375 is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171
    That would require multiple report objects. One report object with different tables for input.

  6. #6
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    So if you have 16 events in an 8 hour day, you are going to create 16 tables? Really?

    Why not have 1 table (since all tables will have the same structure) and append the records to that table?
    Then you would filter the table by "EventId" and "EventDateTime" to view in a form or report/roster list. You can delete the attendees but selecting the "EventId" and "EventDateTime".



    Would have to see your dB to provide a better answer........

  7. #7
    Robyn_P's Avatar
    Robyn_P is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Nov 2017
    Posts
    150
    Have to agree with ssanfu, I think you need to think a bit more about how you're setting up this database. I would have one table to hold the event details (EventID, EventName, EventTime, bla bla) with a 1 to many relationship with a table for the attendees (EventID, AttendeeID, AttendeeName). You wouldn't need a number of attendees field as you can just count the number of attendee records, though if you want to check that you have details for the right amount of people it could be useful. For importing the data from the spreadsheet, you could have a form on which you select the event they are attending and from this get the event ID needed to populate EventID in tblAttendees.

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

Similar Threads

  1. Replies: 0
    Last Post: 06-08-2017, 08:02 AM
  2. Where would you programmatically change a form's property?
    By Access_Novice in forum Programming
    Replies: 2
    Last Post: 12-30-2013, 09:14 PM
  3. How to change report to page 2 programmatically?
    By naeemahmad in forum Reports
    Replies: 23
    Last Post: 12-04-2013, 12:27 AM
  4. Change the record source on my form
    By BigMac4 in forum Forms
    Replies: 4
    Last Post: 09-19-2012, 12:36 PM
  5. Replies: 2
    Last Post: 11-29-2010, 11:16 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