Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Exclude Current Record in SubF
Dan Jackson 
            
4 years ago
Hi Guys,

I have a subform which lists related records. The fields that's related is called CRMSALEID - A 6 digit number.
Its based off a simple query.

What is the best way to exclude/hide the current record from the list? Alternatively, i could use conditional formatting to highlight the current record. Many thanks
Dan Jackson OP  @Reply  
            
4 years ago

Dan Jackson OP  @Reply  
            
4 years ago

Juan C Rivera  @Reply  
            
4 years ago
not sure what your trying to do exclude what?  I say use criteria in your query.  <> PAID.  
try this tech help video maybe it will point you in the direction.
https://599cd.com/blog/display-article.asp?ID=1325

Vr/Juan
Scott Axton  @Reply  
        
4 years ago
For the criteria of your related sales put in <> CRMSALEID .

If you were doing the SQL it would be
   WHERE "CRMSALEID <> """ & CRMSALEID  ' Assuming that CRMSALEID is a number

Basically that says, "show me all records that don't match this ID"
Scott Axton  @Reply  
        
4 years ago
Dan I just got to thinking (dangerous I know).
Try the above but I'm pretty sure it will either fail or not give you the results you want.
You may need to qualify the CRMSALEID using the Forms!FormName!FieldName notation to pull the CRMSALEID from the parent form.

See Value From a Form
Dan Jackson OP  @Reply  
            
4 years ago
@Juan The list includes the record which i'm currently in. It has nothing to do with Status - The "CRMSALEID" is the reference on our other system so its useful in tying all the different records together for the same client. The list, however, includes the current record.

@Scott - Took me a little while to find the SQL. The control source for the control is the Sub Form and the Link Master/Child Fields just referenced the field.
I tried applying your SQL statement directly to the Query which powers the subform to no effect.
I noticed you used CRMSALEID. This will be the same because that's what the subform uses to identify the records. I thought i'd be clever and try the exact same but with WIPID (The P Key) but alas, no joy.
Your second option is a bit too advanced for me at the moment, no idea what it is.

Thank you both
Dan Jackson OP  @Reply  
            
4 years ago
I wonder if i could use a VBA On Load event?
Scott Axton  @Reply  
        
4 years ago
You really don't need an on load I don't think.  You just need to exclude the current record from the Related Sales correct?
What is the name of your parent form?
What is the name of the linking ID(s) between the parent form and the Child (subform)?
Dan Jackson OP  @Reply  
            
4 years ago
Parent Form is 'SalesIndividualViewF'
The Primary Key is 'WIPID'
Both the Master and Child Key is called 'CRMSaleID' which is number only, manually entered
Dan Jackson OP  @Reply  
            
4 years ago
The controls on the forms have the same name as the field but with what the control is before so: Text_CRMSaleID and Text_WIPID
Dan Jackson OP  @Reply  
            
4 years ago
Yes, you are correct
Scott Axton  @Reply  
        
4 years ago
Sorry for taking a bit to get back to this.  The boss actually expected me to do my job...   The nerve of some people.  LOL

So what you want to do is exclude the current form's WIPID from the record(s) found in the query that generates the Related Sales.
That is where you use the Value From a Form video I pointed you to.  
The value you are looking up is like this Forms!SalesIndividualViewF!WPID

Since you don't want the value you use the <>.

So in the query for the Related Sales - The Criteria for the WIPID:

     <> Forms!SalesIndividualViewF!WPID



Scott Axton  @Reply  
        
4 years ago
Sorry Typo:

     <> Forms!SalesIndividualViewF!WIPID
Scott Axton  @Reply  
        
4 years ago
I think you said you found it but...
When you get this working you can view the SQL that Access generates from design mode of the query.
You just go to the Tool Bar and drop down the View button and choose the SQL View.

Access adds in a bunch of stuff that you don't have to have, which can make it confusing to look at, but it's a great way to study and learn the way SQL works.

If you have not already done so, really consider the Access SQL Seminars.  At least 1 & 2.
That will take you to a new level in conjunction with the VBA courses once you get there.  Don't forget to use the special link Richard sent you to get your discount since you are and LC member.
Dan Jackson OP  @Reply  
            
4 years ago
The nerve of some people.... Totally get you! Really appreciate this, i'm going to take a look tomorrow. Thanks Scott
Dan Jackson OP  @Reply  
            
4 years ago
All good and working. Thank You Scott

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 4/30/2026 7:07:20 AM. PLT: 0s