Results 1 to 8 of 8
  1. #1
    PSSMargaret is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    55

    Compare Field in Subform to Field in Another Subform

    Hi all,

    Hoping to get some direction. I have a main form with two separate subforms. I'd like the font of the "Title" field in all of the records in Subform1 to turn red if they don't match the "Title" field in any of the records in Subform2.

    I'm open to conditional formatting or VBA. Any directions would be greatly appreciated.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Why do you have two subforms with same structure?

    Conditional formatting is the only way to do conditional display on Continuous or Datasheet form.

    Use DCount() in the conditional format expression. Or call a custom function in the expression.
    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
    PSSMargaret is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    55
    One of the subforms displays the baselines and other subform displays the actual data. I want the performance data to highlight if someone has entered a dataset with a title that has not been defined in the baselines. Can you give me an idea how to layout the DCount expression?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    DCount("*", "tablename", "[Title]='" & [Title] & "'")>0
    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
    PSSMargaret is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    55
    Well, I'd like to tell you that I've been successful, but I've really been struggling to implement this and hope you are willing to help a little further. Each of the subforms have different IDs (Subform1 is PerformID and Subform2 is IMID). Each of the forms contain the Title field. Also, doesn't your suggestion (below) indicate greater than in stead of indicating that Subform2 doesn't list the Title that is listed in Subform1? Or maybe I'm too tired. Any help is appreciated.

    DCount("*", "tablename", "[Title]='" & [Title] & "'")>0

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Okay, highlight if expression = 0.

    What is your table name?

    Don't know what relevance the IDs have to matching on Title.
    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
    PSSMargaret is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    55
    The mainform data source is qryInd
    Subform1 data source is qryPD
    Subform2 data source is qryJctBase - many-to-many relationship

    I've used Dcount before in VBA to inform the User if they selected a choice that's already been selected and it required IDs because they involved with a table that was a many-to-many relationship.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    You can use whatever fields you want. As long as you pass the correct parameter to the expression.

    You said match on Title fields so that is what my example uses.
    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. Subform Calculated field to another subform
    By tareyj8569 in forum Access
    Replies: 7
    Last Post: 08-26-2015, 01:00 PM
  2. Replies: 3
    Last Post: 04-04-2014, 07:14 AM
  3. Replies: 5
    Last Post: 11-16-2011, 07:30 PM
  4. Replies: 3
    Last Post: 10-03-2011, 02:33 PM
  5. Replies: 7
    Last Post: 07-15-2011, 01:58 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