Results 1 to 9 of 9
  1. #1
    Pawtang's Avatar
    Pawtang is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Mar 2021
    Posts
    91

    Dealing with a filtered form in the event that no records exist for a given foreign key

    My goal is to create an Attachments pop-up form that can be opened for any given primary record. When I open the Attachments form from the primary record interface, it sets the record id to a tempvar and then opens up a continuous form that lists all attachments with a foreign key equal to the id.

    This works fine as long as records exist with that foreign key, but if there are no existing attachments for the id, the form opens to an id of "0". Would it be better to build the form in relation to a query, and then set query constrains based on the TempVar? Or what's the best way to handle this?

    Relationships:



    Click image for larger version. 

Name:	relationships.PNG 
Views:	13 
Size:	54.5 KB 
ID:	46135

    Form design/relevant parameters:

    Click image for larger version. 

Name:	form-design.PNG 
Views:	12 
Size:	19.9 KB 
ID:	46136

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    And this is an issue because ...?

    What do you want to happen - don't open form if no data? Code can do data validation, perhaps with DLookup().
    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
    Pawtang's Avatar
    Pawtang is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Mar 2021
    Posts
    91
    This is intended to be the only interface for adding/opening attachments for a record, so I need to be able to open this interface for a record that does not yet have any attachments, and add them in the continuous form format.

    I originally was designing this as a subform to a parent form that would open to the id, and then link master-child on the id. Is this a better way to handle if I want to be able to add and edit? Halfway through the design I scrapped the parent shell because I thought it was redundant.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Be aware that embedding lots of large files in db uses up Access 2GB limit.

    Why would you think form/subform arrangement is redundant? This is the simplest way to set up data entry/edit for related tables. Little or no code is needed.

    Otherwise, code would validate data and either open form to existing record(s) or to new record row and populate foreign key field.

    I've never used TempVars.
    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.

  5. #5
    Pawtang's Avatar
    Pawtang is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Mar 2021
    Posts
    91
    I am using a file path method rather than attachments for that reason, this will just store file paths to a shared drive and use some code to open them or to browse to the path to build a new connection.

    I suppose I thought the form/subform was redundant because I had a parent shell that presented no unique information that wasn't already present in the child form. However I will give this another shot and see if it solves that problem.

  6. #6
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Quote Originally Posted by Pawtang View Post
    I suppose I thought the form/subform was redundant because I had a parent shell that presented no unique information that wasn't already present in the child form. However I will give this another shot and see if it solves that problem.
    I understand it can seem clunky having to use two separate forms to create a single pop up window but this is probably the easiest way to go. I seem to recall having quirky window issues when trying to use a continuous form as a pop up and had to wrap it in a 'shell' form anyway...

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    So it is not really and Attachment type field?

    Why is parent info repeated in child form? Don't use query that joins the two tables as RecordSource for child form.
    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.

  8. #8
    Pawtang's Avatar
    Pawtang is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Mar 2021
    Posts
    91
    Quote Originally Posted by June7 View Post
    So it is not really and Attachment type field?

    Why is parent info repeated in child form? Don't use query that joins the two tables as RecordSource for child form.
    Not in the standard sense, no.

    Problem was that I had both the parent and the child source set to the table of attachment paths. Now the parent uses the primary records table as record source and matches the child's foreign key with its primary key. Works fine.

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    And that's as it's intended to work. Glad you got it working.
    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. Update Records in Filtered Form
    By PSSMargaret in forum Programming
    Replies: 18
    Last Post: 01-19-2021, 06:08 AM
  2. Filtered Records Wont Stay Filtered
    By ortizimo in forum Access
    Replies: 4
    Last Post: 11-29-2017, 07:08 PM
  3. Replies: 4
    Last Post: 07-10-2015, 07:51 AM
  4. Replies: 12
    Last Post: 03-16-2015, 04:57 PM
  5. Replies: 11
    Last Post: 10-28-2014, 01:24 PM

Tags for this Thread

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