A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Multiple combo boxes



 
 
Thread Tools Display Modes
  #1  
Old November 2nd, 2005, 12:20 AM
Deb H
external usenet poster
 
Posts: n/a
Default Multiple combo boxes

I have a main form and subform with 2 combo boxes. One combo box
(cboFindHH)should filter the main form (based on Families table) and the
other combo box (cboFindChild) should filter the subform (based on Children
table). There is a one to many relationship between the tables. I have
modified code using the tip from Allen Browne's previous posts, but I can't
seem to be able to go from one combo box to the other. For example, if I
filter a particular head of household in the main form, I would then like to
apply a new filter based on all the records in the subform (or do the
reverse). However, when I try this, it is only searching on one record. Here
is my code:
Private Sub cboFindHH_AfterUpdate()
Dim strSQL As String
Dim bWasFilterOn As Boolean

bWasFilterOn = Me.FilterOn

If IsNull(Me.cboFindHH) Then
If Me.RecordSource "Families" Then
Me.RecordSource = "Families"
End If
' If the combo is Null, use the whole table as the RecordSource.
Else
strSQL = "SELECT DISTINCTROW Families.* FROM Families " & _
"INNER JOIN Children ON " & _
"Families.ID = Children.ID " & _
"WHERE Children.ID = " & Me.cboFindHH & ";"
Me.RecordSource = strSQL
End If

If bWasFilterOn And Not Me.FilterOn Then
Me.FilterOn = True
End If

Exit_cboFindHH_AfterUpdate:
Exit Sub

Me!cboFindHH.Requery

End Sub

Private Sub cboFindChild_AfterUpdate()
If IsNull(Me.cboFindChild) Then
Me.FilterOn = False
Else
Me.Filter = "ID = " & Me.cboFindChild & ""
Me.FilterOn = True
End If
End Sub

Any help is appreciated.
--
Deb H
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding a record using multiple combo boxes as my search criteria sdg8481 General Discussion 8 March 8th, 2005 09:36 PM
Combo boxes on forms displaying multiple fields ... Jamie Risk General Discussion 2 February 17th, 2005 02:10 AM
Multiple Combo Boxes??? hce General Discussion 1 September 1st, 2004 06:36 AM
Filtering Records using multiple combo boxes Mark Senibaldi Using Forms 0 June 17th, 2004 03:51 PM
Data Dependencies between Combo Boxes Tom Using Forms 7 June 6th, 2004 05:25 PM


All times are GMT +1. The time now is 11:26 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.