473,770 Members | 6,158 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Filtering two subforms through the main form

129 New Member
Hi can anybody help?

I have a main form with customer details on that links to a sales order head subform through the customer ID. The sales order head subform is then linked to the sales order line through the order no. I need to find a specific sales order number through the main form and once this number is chosen it needs to dispalay the relevant customer and order line details.

I have the following code but it filters the customer Id instead of sales order no, ive tried changing the code around to filter the sales order number but it doesnt work, can anybody help:

Dim strSQL As String
If IsNull(Me.cboSh owOrder) Then
' If the combo is Null, use the whole table as the RecordSource.
Me.RecordSource = "tblCustome r"
Else
strSQL = "SELECT DISTINCTROW tblCustomer.* FROM tblCustomer " & _
"INNER JOIN tblSalesOrderHe ad ON " & _
"tblSalesOrderH ead.CustomerID = tblCustomer.Cus tomerID " & _
"WHERE tblCustomer.Cus tomerID = " & Me.cboShowOrder & ";"
Me.RecordSource = strSQL
End If

If I cant filter from the main form then can i filter in the sales order subform which still allows me to display customer and order line details?
Mar 29 '08 #1
2 1379
JConsulting
603 Recognized Expert Contributor
Hi can anybody help?

I have a main form with customer details on that links to a sales order head subform through the customer ID. The sales order head subform is then linked to the sales order line through the order no. I need to find a specific sales order number through the main form and once this number is chosen it needs to dispalay the relevant customer and order line details.

I have the following code but it filters the customer Id instead of sales order no, ive tried changing the code around to filter the sales order number but it doesnt work, can anybody help:

Dim strSQL As String
If IsNull(Me.cboSh owOrder) Then
' If the combo is Null, use the whole table as the RecordSource.
Me.RecordSource = "tblCustome r"
Else
strSQL = "SELECT DISTINCTROW tblCustomer.* FROM tblCustomer " & _
"INNER JOIN tblSalesOrderHe ad ON " & _
"tblSalesOrderH ead.CustomerID = tblCustomer.Cus tomerID " & _
"WHERE tblCustomer.Cus tomerID = " & Me.cboShowOrder & ";"
Me.RecordSource = strSQL
End If

If I cant filter from the main form then can i filter in the sales order subform which still allows me to display customer and order line details?
Isn't this more of a Go To Record situation, vs a filter situation? Seeing as how your customer is already selected and all. If I understand this right, you may or may not be on the customer record where the Order Number exists? For the sake of arguement, let's say its not. You would first have to use the Order number and pull the CustomerID foreign key number from it. Then you set your main form's recordsource to that customer. Easy enough. Now that you're on the right customer, you use the same logic that a Combo box uses to find a record, to find the right orderID in your subform

Set rs = Me.MySubform.Re cordset.Clone
rs.FindFirst "[OrderID] = " & Me![MyCombo]
Me.MySubform.Bo okmark = rs.Bookmark

then requery the sub-subform.

Hope this helps!
J
Mar 30 '08 #2
Constantine AI
129 New Member
Thank you very much for your help, it does work, I just need to do some tweaking to it now.

Thanks again
Mar 30 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
11104
by: Jason | last post by:
I am trying to filter records in a primary form based on records in related tables. The data in the related tables is being displayed in the primary form through subforms. To be more specific, I have a primary form named TestResults, which is connected to data in a table named TestResults. There are basically two other tables that are related to the TestResults table (and the primary form) named Names-Normalized and SiteAddresses. The...
5
3090
by: Richard | last post by:
Hi, I have a form that take some time to load due to many comboboxes and at least 8 subforms. When I filter or sort the main form I get an error message and then Access shuts down. They ask if I want to send the error report to Microsoft. Has anybody seen this type of error message and what can I do to prevent it from happening. Am I doing something illegal in my code? It used to work but I have added conditional formatting to a subform...
2
3004
by: Jack | last post by:
Hi all, I searched the archives and found everyone happy with Stephen's MouseWheel On/Off code except for those with subforms. Stephen's page indicates that he has added code to handle subforms ("Bug Fix for SubForms with ScrollBars. Bug fix for SubForms without visible ScrollBars.") - BUT I still can't get it to work on my app with my subforms. I'm using Access 2000, It works fine on the main forms but not on the
0
2244
by: Jack | last post by:
Gday everyone, I'm dearly hoping Stephen Lebans is going to update his masterpeice to stop the mouse wheel scrolling to work on subforms *he has indicated this to me but of course beggers can't be choosers here so I have no idea when this would be done*. I'm just wondering if anyone has gotten around the problem some other way? --Original Thread---
7
2332
by: lauren quantrell | last post by:
A while back I got a requirement for the client to be able to adjust the relative heights of two subforms by click-dragging the mouse and I came up with a kludge solution using a border control between the two subforms. But I put my mind to this again recently and came up with a solution (code below) that works well with multiple subforms to size both the heights and widths of the sunforms relative to each other, and it uses no additional...
0
1264
by: Mclaren | last post by:
Hi I have 3 tables: User, Customer and Customer order. I have a query that picks up all the orders captured for a given User. Each of the orders have a capture date. My main form is based on the Users table.
2
1612
by: Katie | last post by:
I need to store a history of two fields in two seperate tables: Event - where the key is Event_ID Stage - where the key is Stage_ID The joins are: Main Table Event Table Stage Table My screen has:
4
6058
by: Harlequin | last post by:
I have a question concerning the need to trigger events within a "child" subform which is itself enbedded within a master "parent" form and which is accessible via a tab in the parent form. Becuase this is all very difficult to explain in words, please bear with me as I endevour to explain what it is I am trying to do. It would be helpful if I could attach a graphics file to this posting that would help explain what it is I'm trying to achieve...
0
2381
by: TD | last post by:
I have a main form with two subforms (both in datasheet view), neither of which are linked to the main form. The main form is based on a query that uses the bound column of a combobox on the main form as the criteria for the query. The combobox is based on a query that retrieves the name and record id of the customers. In the afterUpdate event of the combobox on the main form and both subforms are requeried. The first subform is based...
0
10231
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10059
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10005
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8887
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5452
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3972
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2817
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.