473,378 Members | 1,619 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,378 software developers and data experts.

First Combo box filter work but not sure of second

Hi All,

I have found a lot of info on Combo box in the archive which are very good but some are to advance for me. I tried several options but I had no luck. I was finally able to find a code that I was able to understand completely. Let me explain my situation.

On an unbound form I have created a subform [Employees subform] from tblEmployee. This table contains
EmployeeN, StartDate, Department. On the subform I Have added 2 unbound Combo boxes
CboDepart – Created from table tblDepartment
CboSDate – Created from qry_SDate_Sum. The query is created from [tblEmployee]. It gives a summary of [StartDate], since more that one employee can start on a particular day.

The idea is I from [CboDepart] I can select a particular department and it will list all the employees for the department, then if I select a particular StartDate from [CboSDate] then it will show all employees with the same StartDate for the department.

So far in the AfterUpdate of [CboDepart] I have the following.
Code:
Private Sub CboDepart_AfterUpdate()
Dim strFilter As String

strFilter = "select * from [tblEmployee] WHERE [Department]='" & CboDepart & "';"

Me.RecordSource = strFilter
Me.Requery

End Sub


This works perfectly, where I am stuck is how do I get the second filter [CboSDate] to work. From what I’ve read I think I have to create a link between the combo boxes but I don’t know how. Any guidance would be greatly appreciated.
Nov 25 '07 #1
2 1037
Hi

Try this:


1. Set the data source of the form to tblEmployee

2. In the on_click even of the cboDepart, set the filter of the form AND the rowsource on the cboDate like this:



Private Sub CboDepart_onClick()

Dim strFilter As String

strFilter = "WHERE [Department]='" & CboDepart & "';"

Me.filter = strFilter
Me.filterOn = true

strFilter = "SELECT DISTINCT startDate FROM tblEmployee WHERE Department = '" & me.cboDepart & "'"
me.cboStartDate.rowSource = strFilter

End Sub

3. When a date is selected,use the onClick event in the date combo to re-set the form filter to something like:
Private Sub CboDate_onClick()

Dim strFilter As String

strFilter = "WHERE [Department]='" & CboDepart & "' AND startDate = #" & me.cboDate & "#"

Me.filter = strFilter
Me.filterOn = true

That's a bit rough but should get you going.

cheers

AKC
Nov 26 '07 #2
Sorry it took so long to reply, thanks for the info atkellyx, this helps me out.
Nov 27 '07 #3

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

Similar topics

3
by: RRT | last post by:
I have an existing table which describes Streets and sections of streets between intersections: Table 1: Streets by Intersections Street Area Ann St. Main to Jackson...
5
by: jjyconsulting | last post by:
Newbie needing some help. I have a tblParticipants. The fields include gender, education_level, income, occupation etc., I'm trying to create a form where a user can run a query from the form and...
9
by: natwong | last post by:
Hi All, I'm a newbie in terms of Access and some of its functionality . I've been stuck on this problem for a couple days, even after searching the Web, etc. Currently I have five combo boxes...
3
by: imtmub | last post by:
Hi, I need to filter from one combo box to another in MsExcel. I have two combo box. one is Categary and another is product. If the user select categary depend on that second combo box filter only...
5
by: consonanza | last post by:
I am working on a report filter form. It has 2 combo boxes (cmboSelectSubject and cmboSelectCategory) to select criteria. Selecting an entry in combo 1 restricts the options available in combo 2....
6
by: fieldja | last post by:
I have a form called OwnerForm. It contains a combo box called Owner. The combo box looks up names from a table called OwnerName. It contains fields called OwnerID and Owner. I also have a main...
2
by: chittaranjan sahoo | last post by:
hi, i want to connect two combo boxes in sucha way that when a value in first combo is selected, in the second combo,it should show only the values related to one selected in first combo box. the...
6
by: bammo | last post by:
MS Access 2003, Windows XP SP2, VBA I have a continuous form that allows edits and filters, but not deletions or additions. I filter the form based on combining selections the user makes in...
8
by: troy_lee | last post by:
I want to look at the values of six combo boxes. If any of the boxes are not null, I want to change the value of a separate text box. How can I look at all of them at once? Thanks in advance. ...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.