Results 1 to 7 of 7
  1. #1
    Eddy Sincere is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2014
    Location
    Carson City, NV
    Posts
    114

    Subform and query not displaying information based on input from a primary form

    I have a simple Form/Sub form design where the sub form displays records based on data in a text box on the primary form. I use two scroll buttons so the user can shift between records but the data in the sub form isn't changing.

    Primary form = frmLbl

    Sub form = SF01Clrs
    Sub form query = qryLBL01N01Clrs

    I know this is a simple answer, but I cannot figure out what's wrong. I've attached the DB for reference. Any help is appreciated.
    Attached Files Attached Files

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by Eddy Sincere View Post
    ...where the sub form displays records based on data in a text box on the primary form...
    Have you used the Link Child Fields and Link Master Fields properties of your Subform control?
    https://msdn.microsoft.com/en-us/lib.../ff195880.aspx

  3. #3
    Eddy Sincere is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2014
    Location
    Carson City, NV
    Posts
    114
    Yup. It doesn't work.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Actually, the Master/Child Links properties are not set. Unfortunately, setting them causes 'expression too complex error'. Odd. I rebuilt forms and the linking works.

    ItmNmbr in Itm is described as "Item Number of the product, must be unique" yet it is set for Indexed Yes (Duplicates OK). This is contradictory.

    Remove the dynamic parameter from the subform RecordSource query. It is useless. Subform loads before main form - I know sounds backwards but is true.
    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
    Eddy Sincere is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2014
    Location
    Carson City, NV
    Posts
    114
    Yes, I deleted the Master/Child properties because I kept getting the error message. And, I didn't really need it because I just made the field in the query equal the Master form (Forms!frmLbl!IDItm). Quick question - Is it good practice to set the Master/Child relationship? Or should I leave it blank and set the query criteria to pull based on the Master form?

    Also, I did have the ItmNmbr as the primary key, but switched it because it's a short text field and not an autonumber field. Once I switched the PK the error message started and the query stopped working. The contradiction is due to me forgetting to change the text in the description.

    I was really hoping that I was overlooking something simple (which is usually the case) so that I wouldn't have to rebuild the form. However, it looks like a rebuild is in order.

    Thanks for taking the time to answer my question, especially on a weekend!

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Subform query referencing main form field won't work because as noted, subform loads before main form so the field from main form is not available to the subform when it loads. And the subform won't automatically requery when navigating main form records.

    Master/Child Links properties are intended to synchronize main and subform related records.

    I don't know what was causing the error. I couldn't see anything in the VBA procedures to cause issue. Sometimes objects get corrupted and cause can never be determined.

    Create new forms and can probably copy/paste controls from the originals without propagating the error but sometimes controls can become corrupted. Code will not accompany the copied controls.
    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
    Eddy Sincere is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2014
    Location
    Carson City, NV
    Posts
    114
    Got it! Thanks for the information regarding Master/Child relationships, it's very helpful. This thread is solved.

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

Similar Threads

  1. Replies: 1
    Last Post: 11-28-2012, 01:33 PM
  2. Set Current Record based on Primary Key Input
    By andersonEE in forum Forms
    Replies: 2
    Last Post: 06-24-2011, 08:23 AM
  3. Replies: 4
    Last Post: 03-20-2011, 08:45 PM
  4. Subform Filter based on Main Form Information
    By james.carpenter2 in forum Forms
    Replies: 0
    Last Post: 02-16-2011, 09:55 PM
  5. Replies: 1
    Last Post: 06-14-2010, 02:31 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