473,325 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

How to filter subform in a form using another form?

222 100+
Hello

Working on access 2007. My database file is made on access2003.

I have 2 forms. (categories) and (Productlistsearch).

The Productlistsearch form contain a subform called "Products subform"

I want to open "Productlistsearch" from "categories" where CategoryID in "Products subform" = categoryid in categories.

I tried many syntax but unfortunately I didn't success.
This is my last method that I used.
Expand|Select|Wrap|Line Numbers
  1.  
  2.   Dim stDocName As String
  3.     Dim stLinkCriteria As String
  4.     stDocName = "Productlistsearch"
  5.     stLinkCriteria = "Forms![Productlistsearch]![Products subform].Form![CategoryID]=" & Forms![categories]![CategoryID] & ""
  6.      DoCmd.Close
  7.     DoCmd.OpenForm stDocName, , , stLinkCriteria
Any suggestion would be appreciated

THANK YOU

WASSIM S DACCACHE
Oct 26 '08 #1
2 15097
Stewart Ross
2,545 Expert Mod 2GB
Hi Wassim. You cannot filter the subform on open the way you are trying to do - the linkcriterion applies to the main form's recordset, not its subform's one.

You could try opening the form, then filtering the subform using its own filter property as follows. I assume that CategoryID is a string - if it is a number you will not need the single quotes on either side of it in the filter string.
Expand|Select|Wrap|Line Numbers
  1.  
  2.     DoCmd.OpenForm stDocName
  3.     with forms(stDocName)![Products subform].Form
  4.       .filter  = "[Category ID] = '" & Forms![Categories]![CategoryID] & "'"
  5.       .filteron = True
  6.     end with
If you need to close the Categories form before you open the products form then store the value of CategoryID in a variable before you do so, using the variable in place of the direct reference to the CategoryID control in the filter string.

-Stewart
Oct 26 '08 #2
wassimdaccache
222 100+
Hi Wassim. You cannot filter the subform on open the way you are trying to do - the linkcriterion applies to the main form's recordset, not its subform's one.

You could try opening the form, then filtering the subform using its own filter property as follows. I assume that CategoryID is a string - if it is a number you will not need the single quotes on either side of it in the filter string.
Expand|Select|Wrap|Line Numbers
  1.  
  2.     DoCmd.OpenForm stDocName
  3.     with forms(stDocName)![Products subform].Form
  4.       .filter  = "[Category ID] = '" & Forms![Categories]![CategoryID] & "'"
  5.       .filteron = True
  6.     end with
If you need to close the Categories form before you open the products form then store the value of CategoryID in a variable before you do so, using the variable in place of the direct reference to the CategoryID control in the filter string.

-Stewart
Stewart it worked properly. Appreciate you from the deep of my heart.
you saved my time

Thank you again
Oct 26 '08 #3

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

Similar topics

1
by: Robert Neville | last post by:
I would like to add filter functionality to my database whether through the Main form or the subform. This question may be rudimentary, yet I have not less experience with filtering data outside...
2
by: Andante.in.Blue | last post by:
Hi everyone! I was wondering if there is a away to use Access 97's build in filter-by-form function but restrict its effect to just the subform. I have a parent form that shows the major...
7
by: damjanu | last post by:
Hi All; I need little help. I have a datasheet form. I allow user to do 'filter by selection'. My form contains a column with values. As user changes selections, I want to calculate totals....
2
by: cefrancke | last post by:
I have a form (no underlying record set) that has two separate sub-forms on it. Each sub-form has data from two different tables. Above each sub-form there is one unbound combo box with a SQL...
4
by: MS | last post by:
I'm having trouble applying a filter to a subform. I create a String in a Module based on various selections on the form. Clicking a button on the "stand alone form" that changes the filter...
2
by: Lenin Torres | last post by:
Hi everybody I have an Union Query that works fine. I used this query as the RecordSource for a Form. That Form is used as a subform in another form. Everything works fine, except for the "Filter...
3
by: dhowell | last post by:
In reading some of the posts on this group, it appears as though it is not strait forward at all to filter a form, which has subforms, by criteria which are either on subforms or span more than one...
2
by: Matthew Wells | last post by:
Hi there. I am a programmer for a living, but this problem has my whole team stumped. I have a subform based on a query. I'm not using the "LinkMaster/ChildFields" properties ( I have my...
0
by: diogenes | last post by:
"Rick Brandt" <rickbrandt2@hotmail.comwrote in news:bPnKj.456$%41.325 @nlpi064.nbdc.sbc.com: I used this approach, and it works a treat! ID In(SELECT Order_ID FROM orderitems WHERE NAME =...
2
by: franc sutherland | last post by:
Hello, I am using Access 2003. I have a query which shows a list of club meetings sorted by date. This query is displayed in continuous forms, in a subform. I would like to select a month on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.