473,404 Members | 2,195 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,404 software developers and data experts.

Selection Criteria using multiple combo boxes on form witha subform

This database is used to track TV series that are being watched or have been watched.
I have multiple combos on a tab form to to use as filter options. After making selection in the verious combo boxes, I then choose a to click (prodecure Event) buttton that uses the following Code to anylize the records.
Expand|Select|Wrap|Line Numbers
  1. Private Sub btn_Select_Records_Click()
  2. On Error GoTo Err_btn_Select_Records_Click
  3.  
  4.     Dim xAnd As String
  5.     Dim SelCrit As String
  6.     Dim stDocName As String
  7.     Dim stLinkCriteria As String
  8.  
  9.     stDocName = "Frm_TV_Series_Edit"
  10.  
  11.     'Selection Criteria
  12. 'Intialization
  13.     xAnd = ""
  14.     SelCrit = ""
  15. 'This Section Processes Series Items for a specific Series
  16.     If IsNull(Me![Select_Series_Name]) = False Then
  17.     SelCrit = SelCrit & xAnd & "[TV_Series_Name_ID] =" & Me![Select_Series_Name]
  18.     xAnd = " And "
  19.     End If
  20. 'This Section Processes Series Items for Specific Source
  21.     If IsNull(Me![Select_Series_Source]) = False Then
  22.     SelCrit = SelCrit & xAnd & "[Source_ID] =" & Me![Select_Series_Source]
  23.     xAnd = " And "
  24.     End If
  25. 'This Section Processes Series Items for Specific Status
  26.     If IsNull(Me![Select_Series_Status]) = False Then
  27.     SelCrit = SelCrit & xAnd & "[Viewing_Status_ID] =" & Me![Select_Series_Status]
  28.     xAnd = " And "
  29.     End If
  30.  
  31.     DoCmd.OpenForm stDocName, , , SelCrit
  32.  
  33. Exit_btn_Select_Records_Click:
  34.     Exit Sub
  35.  
  36. Err_btn_Select_Records_Click:
  37.     MsgBox Err.Description
  38.     Resume Exit_btn_Select_Records_Click
  39. End Sub
The form Frm_TV_Series_Edit has a subfrom frm_Season. The form uses a query that includes the tbl_TV_Series and directley related tables.
The subform uses a query that includes tbl_TV_Season and some dirctely related tables. The two queries use the (PK)TV_Series_ID.

The select Specific Series and Specific Status work just fine (the are associted with the main form query). The select Specific Source does not work (it is associted with the subform query)

I know I need different syntax other than just "[Source_ID] =" since it should be comparing the field on the subform (not the main form) with the combo box Me![Select_Series_Source].

I know that the subform is considered a control but after extensive searching online and reading - (lots of trial and errors) - I just can't figure out the correct syntax.
Jul 3 '16 #1
4 1056
NeoPa
32,556 Expert Mod 16PB
You may find the following links helpful :
Referring to Items on a Sub-Form.
Example Filtering on a Form.
Let us know if you still have problems. If so, explaining exactly what and where your problem is would be likely to encourage other experts to offer help.
Jul 7 '16 #2
Here is code that I have which can't find the Source_ID on the main form (query) that being called - it needs to look at the subform to find Source_ID.
Expand|Select|Wrap|Line Numbers
  1. 'This Section Processes Series Items for Specific Source
  2.     If IsNull(Me![Select_Series_Source]) = False Then
  3.     'SelCrit = SelCrit & xAnd & "[Source_ID] =" & " & Me![Select_Series_Source]"
  4.     xAnd = " And "
  5.     End If
I tried the various syntax examples that should refer to the subform and its Source_ID; the "[Source_ID]" needs to replaced with syntax that refers to the subform.
I tried Me.[frm_Series]![Source_ID] - it still can't find the Source_ID which needs to match [Select_Series_Soure] which is from a combo box on the selection criteria form.

I guess I am just to old to understand this!

I am happy to post whatever is needed - this is the first time that I had to deal with the kind of one to many relationships (where the form has a subform)
Jul 7 '16 #3
NeoPa
32,556 Expert Mod 16PB
This may be tricky then. I need more info from you in order to give specific answers. The linked article is my attempt to explain the concepts as clearly as possible without a specific scenario.

We often to a bit of extra hand-holding - and that's fine - but I'd need to know the names of all the relevant objects and how they relate to each other in order to understand your situation fully enough to walk you through it.

Maybe you could use the linked article to go through your form structure and post here what's what.
Jul 8 '16 #4
Expand|Select|Wrap|Line Numbers
  1. 'This Section Processes Series Items for Specific Source
  2.     If IsNull(Me![Select_Series_Source]) = False Then
  3.     SelCrit = SelCrit & xAnd & " [Source_ID] =" & " & Me![Select_Series_Source]"
  4.     xAnd = " And "
  5.     End If
Okay! To start with I have a form with tabs , Select Series, Reports, & Edit Fields. The Select Series tab has three combo boxes to pick what is to be selected; Series, Source, & Status.

The form that is being called for is Frm_TV_Series_All that uses a query Qry_Main. That form has a subform (Frm_Season) that uses a query (qry_season) the form and subform are linked with Series_ID. The Series & Status selection criteria work fine because they are attributes of the form (Frm_TV_Series_All) and its query.


I change the code to try to get it to refer to the subform which has the Source_ID
Expand|Select|Wrap|Line Numbers
  1. 'This Section Processes Series Items for Specific Source
  2.     If IsNull(Me![Select_Series_Source]) = False Then
  3.     SelCrit = SelCrit & xAnd & " Me.[frm_Season].Form.[Source_ID] =" & " & Me![Select_Series_Source]"
  4.     xAnd = " And "
  5.     End If
I get the followig error: Syntax error (missing operator) in the query expression 'Me.[Frm_Season].Form.[Source_ID] = & Me![Select_Series_Source]

The Select_Series_Source is the name of the combo box on the Series tab of the selection criteria form.
Jul 8 '16 #5

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

Similar topics

2
by: Damon Cherne | last post by:
Here is my issue. I have created a form called “Search” that has several unbound combo boxes, one for each of the attribute that match a column in the Table . Each combo box has input from a...
2
by: visionstate | last post by:
Hi there, I am working on a form that uses 3 text boxes and 3 combo boxes. When any data is entered into any of these, I click a command button and this requeries a sub query in the form and...
1
by: Shawn Yates | last post by:
It has been a while since I have done anything on MS Access and I seem to be a bit rusty. I hope someone could help me solve my issue. I have a form that has multiple combo boxes on it. Each box...
2
by: SPOILED36 | last post by:
I am building a database to track attendance. I have one main form with multiple subforms. Within one of the subforms name sfrDailyAttendance, I also have cascading combo boxes (cboCategory and...
5
by: samdev | last post by:
I have created two combo boxes in a subform.... For example 1. Combo Box State 2. Combo Box City 3. When a state from the Combo Box State is selected, the City combo box updates to reflect...
12
by: micarl | last post by:
How would i print a report based on criteria selected from several Combo Boxes as well as multiple Multi Select List Boxes, that are located on the same form? I can get one Multi List Box, just...
0
by: sarvmardan | last post by:
how to open a report in access containing filtered data using two combo boxes on form and a button to click. let i have two fields and other is . two comboboxes are combo11 and combo9. plz post...
1
by: Yasmeen Pannu | last post by:
HI, I am new to MS Access and stuck in a problem from few days. My Question: I have 3 combo box (Submitter, date from and date to) on my form and i want that when i select values from each of...
8
by: wirejp | last post by:
I am using Microsoft Access 2010.I am trying to perform a search in a form (this form is a continuous form) using two combo boxes: a combo box called ClientID and another combo box called...
5
by: laht0028 | last post by:
Hello, I'm attempting to create a form where the multiple combo boxes are cleared when I proceed to the next record. I have applied the below code and it works to clear one of the combo boxes but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.