Results 1 to 5 of 5
  1. #1
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451

    open form and set recordsource


    I have a start form with options of running a few differant queries, and a display form with a blank subform, no recordsource. what i envision is that when the user selects a query from the start form i would like to open the display form with the selected query as the recordsource for the subform of the display form. I haven't tried this but just the little bit of research i've done suggest that possibly use OpenArgs could do it. Can anyone point me in any direction, am i on the right path or is there a better way. Basicly the subform of the display form could be one of three differant recordsources. thanks.

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I don't think OpenArgs will work by passing a recordsource (query), but I could be wrong. You'll have to try it.

    Since you would be on a mainform (so to speak - the newly opened form w/subform), you could try this syntax
    Code:
    Me!Subform1.Form.RecordSource = "SELECT blah blah yada yada"
    See http://access.mvps.org/access/forms/frm0031.htm



    I have heard of having 3 hidden subforms and use Openargs to pass a 1, 2, or 3, then a "Select Case" would set the visible property of one subform to TRUE.

    Be aware that the data in a subform gets populated before the main form data.

  3. #3
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    Thanks Steve, just thinking outside the box on this one while trying to learn something new. My thought was if all my forms are the same except the recordsouce, simple form with a subform, could i just use a singe form and just pass it a different recordsource that is based on the different queries. I guess since they are each based on queries i could assign each SQL a different number on the subforms load propertie, 1="select blah blah from blah, 2=select 1 from blah, and then use your ideal of passing a value with a openarg from the main form. Then a select case on the display form load to define the recordsource of the subform based on the value of the openarg passed? Sounds doable, i'll play with it.

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    What about control sources?
    Don't the different queries have different field names in the record sources? Which would mean you would have to change the control source for each control.
    Sounds like a *lot* of work/code.....

  5. #5
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    Good point

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

Similar Threads

  1. Report RecordSource record count at Open
    By GraeagleBill in forum Reports
    Replies: 11
    Last Post: 04-19-2013, 02:03 PM
  2. RecordSource Property of a form
    By mkc80 in forum Access
    Replies: 4
    Last Post: 08-11-2012, 05:43 PM
  3. Replies: 8
    Last Post: 05-10-2012, 10:57 AM
  4. Update recordsource of one field on a form
    By TinaCa in forum Programming
    Replies: 1
    Last Post: 03-06-2012, 06:56 PM
  5. Replies: 8
    Last Post: 08-08-2011, 02:05 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