Help with Expression

spectraflame

Well-known Member
Joined
Dec 18, 2002
Messages
830
Office Version
  1. 365
Platform
  1. Windows
I have a combo box that list the different departments (WTOType). Based on the users selection, a query is run to refresh another combo box (Project#). The Project# box gets its data from a table that has project number and department. This works really well right now. However I would like to modify the expression to allow all of the project numbers to appear when a specific department is selected, but still limit the project numbers to the rest of the departments.

EX.

When the Electric department is selected, I currently only see the Electric Project#'s. This is the same for the rest of the departments.

However, when the department = Maintenance, the project field is blank because there are no specific project numbers defined for maintenance. The maintenance department would have the ability to assist with any project.

I am just not sure how to create the expression. I was thinking something like:

IF WOType = "Maintenance" return all project numbers in the project number table, but if the department does not = "Maintenance" run the query based on the selected department.

I have not quite figured out all of the code stuff yet.

Thanks,
Matthew
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
I think found what I was looking for.

I created two queries; one to look at all departments and the second one to run just the specific department from the department combo box.

I used an If state on the after change event of the Department combo box that changed which query was ran.

Ex:

If Me.WOType = "Maintenance" Then
Me.Proj_.RowSource = "MaintProjectqry"
Me.Labor.RowSource = "MaintLaborqry"
Else
Me.Proj_.RowSource = "DeptProjectqry"
Me.Labor.RowSource = "DeptLaborqry"
End If

Matthew
 
Upvote 0

Forum statistics

Threads
1,221,814
Messages
6,162,132
Members
451,743
Latest member
matt3388

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top