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
- Private Sub btn_Select_Records_Click()
- On Error GoTo Err_btn_Select_Records_Click
- Dim xAnd As String
- Dim SelCrit As String
- Dim stDocName As String
- Dim stLinkCriteria As String
- stDocName = "Frm_TV_Series_Edit"
- 'Selection Criteria
- 'Intialization
- xAnd = ""
- SelCrit = ""
- 'This Section Processes Series Items for a specific Series
- If IsNull(Me![Select_Series_Name]) = False Then
- SelCrit = SelCrit & xAnd & "[TV_Series_Name_ID] =" & Me![Select_Series_Name]
- xAnd = " And "
- End If
- 'This Section Processes Series Items for Specific Source
- If IsNull(Me![Select_Series_Source]) = False Then
- SelCrit = SelCrit & xAnd & "[Source_ID] =" & Me![Select_Series_Source]
- xAnd = " And "
- End If
- 'This Section Processes Series Items for Specific Status
- If IsNull(Me![Select_Series_Status]) = False Then
- SelCrit = SelCrit & xAnd & "[Viewing_Status_ID] =" & Me![Select_Series_Status]
- xAnd = " And "
- End If
- DoCmd.OpenForm stDocName, , , SelCrit
- Exit_btn_Select_Records_Click:
- Exit Sub
- Err_btn_Select_Records_Click:
- MsgBox Err.Description
- Resume Exit_btn_Select_Records_Click
- End Sub
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.