Forms :: Filtering List Box Using A Date Rage And Combo Selection
Jan 5, 2014
I am using this code to filter a List Box based on a Date range and a Combo Box selection:
Code:
Private Sub Combo139_AfterUpdate()
Dim StrgSQL As String
StrgSQL = "SELECT [User Name], [Date Of Request], [Description of Problem], Status, Sub_Job FROM QRY_SearchAll " & _
"WHERE [Date of request] BETWEEN #" & CDate(Me.txtStartDate) & _
"# AND #" & CDate(Me.txtEndDate) & "#;"
StrgSQL = StrgSQL & " WHERE Sub_Job = Combo139"
Me.SearchResults.RowSource = StrgSQL
Me.SearchResults.Requery
End Sub
However, It is not working. when I click the Combo box the List Box comes up blank.
View Replies
ADVERTISEMENT
Jul 19, 2013
I have a combo box on a form which has a row source type of Value List in which I've manually typed in 2 entries: Owned, Leased.
I have a query which filters on the results of the combobox, and works fine for when I select either option Owned or Leased.
Is there an easy way to filter all (both Owned & Leased)? I've tried leaving the combobox blank, and tried entering a * in the value list, but they both return no results.
Code:
SELECT Assets.*
FROM Assets
WHERE (((Assets.Possession)=[Forms]![Home]![Combo56]));
View 4 Replies
View Related
Mar 11, 2015
I'm creating a form that when the user selects the following categories in the same combo box (Date Received, Date Reviewed, Date kitted, In Work, Complete) it auto populates dates in the respective fields. As I mentioned, it's only one combo box. The dates will be spread out, so the user will change the combo box selection based on when these events occur. I already have a field for each category both on the table and form. Also, I do have multiple tables for other parts of data, but these categories all fall into the same table.
View 8 Replies
View Related
Oct 27, 2014
I am designing a nomination form (web database so no vba macros can be used).
The form has 3 combo boxes: cboStaffName, cboLevel, cboNominee.
The form is bound to the tblSubmit table where the submissions are populated.
I used a select statement:SELECT Staff_List.Staff_Name FROM Staff_List; to populate the combo box for the Staff Name selection.
This is the select statement to populate the job level combobox:
SELECT Staff_List.Level, Staff_List.Staff_Name FROM Staff_List WHERE (((Staff_List.Staff_Name)=[forms]![frmtest]![cboStaffName]));
The select statement to populate the combobox for the nominee combobox:
SELECT Staff_List.Staff_Name FROM Staff_List WHERE (((Staff_List.Level)=[forms]![frmtest]![cboLevel]));
The problem is that the staff_name in the first combobox is still found in the nominee combobox which should not be because a staff cannot nominate self. There is a field in the Staff_List called YesNo that should be activated for each staff that is selected so that the select statement on the nominee combobox can be updated accordingly to remove items with the field "Active"
How to get the checkbox selected for each corresponding staff.
Sample of the database has been attached.
View 4 Replies
View Related
Feb 18, 2006
Hi, I need help on my search command. I am hoping to be able to use a combo box or a list box coming from a table as my criteria to use to filter records from a form and present it a subform/subreport upon clicking the command button. Ideally I should have a form wherein I will have a either a combo box or list box for my criteria, a subform/subreport, and a command button. When I select a particular item on the combo box or list box and I click the command button, the subform/subreport would show me records matching only the particular criteria I selected.
I tried using several approach but it's not working, I don't know what I'm doing wrong. Please help me, I am just learning how to do this all by myself.
First Approach:
I tried using a list box to list all the countries I have available from the country table and a command button so when I select a country from the list box and click on the command button I will be able to show on a datasheet view only records matching the country criteria.
This is the code I used:
__________________________________________________ _______________
Private Sub Preview_Click()
DoCmd.OpenForm "qrysumcountry subform", , "Country", "Country = [List4]"
End Sub
__________________________________________________ _______________
But everytime I click on the command button Preview, I am always asked to enter parmeter value then when I type the country that's when it shows the record in forms format matching the criteria country but when I dont type anything and click ok, it just shows a blank form and indicates it's filtered but no record is showing. But I click cancel, it shows a Run-time error '2501'. why does it still have to make me type the parameter if I have selected it on the list box already?
Second Approach:
On the form: I used a combo box, a subform/subreport and a command button. On the combo box I have to show different countries available on my country table. on the subform/subreport I have used my a form created from a query. I want to select from the combo box a particular country and used it as my criteria to filter the records I have on my subform when I click on the search command button. I tried following the sample given by gromit but it doesn't want to work on my database.
This is the code I followed:
__________________________________________________ _______________
Private Sub btnClear_Click()
Dim intIndex As Integer
Me.cmbCountry = 0
End Sub
Private Sub btnsearch_Click()
Me.frmqrybyCountry1.Form.RecordSource = "SELECT * FROM qrybycountry" & BuildFilter
Me.frmqrybyCountry1.Requery
End Sub
Private Function BuildFilter() As Variant
Dim varWhere As Variant
varWhere = Null ' Main filter
'Check if there is a filter to return...
If IsNull(varWhere) Then
varWhere = ""
Else
varWhere = "WHERE " & varWhere
' strip off last "AND" in the filter
If Right(varWhere, 5) = " AND " Then
varWhere = Left(varWhere, Len(varWhere) - 5)
End If
End If
BuildFilter = varWhere
End Function
__________________________________________________ _______________
After selecting on the combo box and click on the command button it just shows all record. It doesn't seem like it is reading what I selected from the combo box as my criteria to filter the records. What could be I be doing wrong? Honestly, I dont understand what is happening to the code here especially the BuildFilter function.
Please help me, I would really want to figure this problem out. Thank you so much.
View 2 Replies
View Related
Dec 12, 2006
Hello,
Didnt know where to start or what direction to head in. I have a combo box on one of my forms. It works fine, but would am looking for an added feature.
I am looking to get the following started:
There are 5 items in the list of my combo box. If the user selects the item called "Lost Opportunity", then how do I get an additional combo box to show up underneath it with reasons the sales opportunity was lost.
Then the reasons why would be in the additional box and they would have to select one...my work wants it so that if they lose the sale, they must provide a reason for that loss of business.
Any help in a direction would be appreciated.
Thanks.
View 4 Replies
View Related
Sep 23, 2005
(pls see end of thread for further clarification)
Hi
I am trying to achieve the following using 2 combo boxes
Box "a" is a list of courses from tbl_training_courses. The user selects the appropriate course.
Box "b" is a list of dates for each course from tbl_course_dates. Thus the user can select which date per course they want to book someone onto, and this value is then stored in tbl_training_record as the date the person is booked onto.
Its not working!!! It either displays blank values, or it starts a parameter query which I didnt want.
In the combo wizard, access refers to "remembering the value selected for later use" - i guess this might be what I need to use, remembering the value from the first and using it to select rows for the 2nd box based on identical courseID - but I can't seem to find this in Help file.
Any ideas anyone?
View 6 Replies
View Related
Feb 1, 2006
I have quite a simple problem I think, but i don't know if I'm able to explain it properly.
I have three tables:
one for contacts
one for the groups contacts are a member of
and a junction table to solve the many to many relationship there.
What I want, is to create a form, with a combo box with a drop down list of groups. When a user selects a group, I'd like all the contacts (including *some* of their fields) to populate the list box below.
So a user can easily view the members of each group.
Does that make sense?
View 6 Replies
View Related
Dec 11, 2014
I am using access 2010
I am trying to get my list box to filter based on the selection of a combo box.
My Combo box cboOrgRole is on my main form and is bound to OrgRoleID - on form - frmOrgEntry
The unbound list box lstRoleList is in a tabbed subform - frmPersonnel
This is my data pull for lstRoleList
Code:
SELECT tbl00PersonRole.PersonRole, tbl01Orgs.OrgRoleID
FROM tbl00PersonRole INNER JOIN tbl01Orgs ON tbl00PersonRole.OrgRoleID = tbl01Orgs.OrgRoleID
WHERE (((tbl01Orgs.OrgRoleID)=[Forms]![frmOrgEntry]![OrgRoleID]));
This is the code I have on cboOrgRole AfterUpdate
Private Sub cboOrgRole_AfterUpdate()
Me.frmPersonnel.lstRoleList.Requery
End Sub
I have also tried Recalc - both throw a Compile error: Method or data member not found
My goal is to be able to select the role of the organization, (General Contractor, Architect, Engineer, or Client) and have it list the available titles for the specific organization type.
My "00" tables are library tables
View 12 Replies
View Related
Jun 30, 2015
I'm trying to set up my own form for my customer contacts.
I have TABLE A that lists general customer information.
I have TABLE B that lists customer branches (each customer has multiple branches).
I have a combo list set up so that if I select a customer name, the rest of the form populates with the customer general information.
Is there any way I can filter out a list depending on what customer is selected?
I only want to see the branches of the customer I've selected on the COMBO box.
View 2 Replies
View Related
May 20, 2013
I am wanting to preempt data in list boxes
listbox1
Fruit
Vegetable
listbox2 (If Fruit Is Selected)
Apple
Banana
Orange
listbox2 (If Vegetable Is Selected)
Potato
Peas
Carrot
If Fruit is selected in Listbox1 - Then Listbox2 should have the options
Apple
Banana
Orange
If Vegetable is selected in Listbox1 - Then Listbox2 should have the options
Potato
Peas
Carrot
View 12 Replies
View Related
Jun 15, 2013
I have a list box which gets it's data from a query. I would like to filter this query to show only those rows matching a value displayed on the form.
The form displays data from a table and has a text box named PIDLocal.
The query returns a list of PID values and some text SELECT PID, Country, RefCode FROM Query1 The PIDs are integers.
I want the list box to contain only those rows where PID = PIDLocal.
I have tried setting the criteria in the row source query to PID = [Forms]![Show_Details]![PIDLocal], but nothing is returned. If I 'hard-code' a value (eg PID=247) I get the desired result.
View 1 Replies
View Related
Apr 27, 2013
I have a Suppliers database which contains a form that will allow me to place orders with Suppliers.The Main form has a combo box that allows me to select the supplier. The combo box is called SupplierID with the following:
Row source: SELECT Suppliers.SupplierID, Suppliers.CompanyName FROM Suppliers ORDER BY Suppliers.CompanyName;
The subform is called Stock Subform witha combo box called ProductID with the following:
Row source: SELECT DISTINCT Products.ProductID, Products.ProductName, Suppliers.CompanyName, Products.Discontinued FROM Suppliers INNER JOIN Products ON Suppliers.SupplierID=Products.SupplierID WHERE (((Products.Discontinued)=0)) ORDER BY Products.ProductName;
Event Procedure - AfterUpdate: Private Sub ProductID_AfterUpdate()
On Error GoTo Err_ProductID_AfterUpdate
Dim strFilter As String
' Evaluate filter before it's passed to DLookup function.
strFilter = "ProductID = " & Me!ProductID
[code]..
The Link fields are done on the Purchase Order ID (PONoID).What I want to achieve is to select the supplier from the combo box (SupplierID) on the main form and then the combo box (ProductID) on the subform to filter to only show products directly supplied by the Supplier selected on the Main Form.
View 11 Replies
View Related
Jun 3, 2014
I am trying to select a value from one combo box and on the basis of this selection the other combo box show only those values which have link to the value I have selected.
View 14 Replies
View Related
Dec 2, 2014
I currently have a form that only shows data based on a specific record id. I have placed a list into that form though that has multiple record ID's listed ( It's a log). How do I get a List to Filter to just the Record ID that corresponds to the current form Record.
What I have are as follows:
A form that has client information : Address, phone numbers, Etc.
On that form I have Pages. one of the pages contains a List.
That List however contains information from multiple clients based on Point of Contact ( Call Log)
What I want is a way to narrow the List to only show those that corresponds to the Current Client Record.
Is this possible? If my approach is wrong, which is a better way?
View 1 Replies
View Related
Mar 21, 2013
I have three linked tables [Regulator], [RuleBook] and [Rules] (each has a corresponding form for data entry).
In the "Rules" form, when you select name of the regulator, the rule books dropdown down is filtered to show only the rulebooks for that regulator. the code I use is:
Private Sub Regulator_Change()
Me.[Rule Book].RowSource = "SELECT [ID],[Rule Book],[Short Code],[Regulator],[RegName],[Short Form],[Active] FROM" & _
" [RuleBook] WHERE Regulator = " & _
Me.Regulator
Me.[ShortReg] = Me.Regulator.Column(3)
End Sub
Basically, if I select the FSA as the regulator, The Rule Books drop down is filtered to only show the FSA Rule Books. If I pick OFT, I get the OFT list etc. This all works fine.
In the [RuleBook] table, each entry has a yes/no tick box called "Active".
The reason for this being that the regulators change their rule books quite regularly, but from an audit perspective, I can't delete or overwrite the old ones once they are no longer valid.
What I want to do, is further filter the rule book list to those where Active=True so that when I select FSA, I can only choose from their current rule books and not the ones that are no longer relevant.
View 7 Replies
View Related
Jan 12, 2005
Porbably a stupid queston for most of you, but I am new to the game. Trying to get the selection of one combo box to filter the selections of a second combo box. Have one table called Sections with the colums SectionID and SectionName, a Second Table called SubSection with Colums SubSectionID, SubSectionName, and SectionID. Third Table called Points which has a column for Section, and SubSection, need to have the section combobox selection filter the SubSection combobox selections. Any help would be appreciated!
View 1 Replies
View Related
Jul 10, 2013
I've been working on this application for a long time, and my combo box always behaved well before, but today I click on the combo box, the list drops down, but I can't select anything. I've also tried typing the item on the list into the combo, which normally works, but I'm not being allowed to type anything there.
View 6 Replies
View Related
Aug 12, 2013
Is there an easy way to store a multiselect list box selection?
View 1 Replies
View Related
Jul 2, 2013
I have a form that is bound to Table1 and I am using the value from a Combo box to filter the records. The Combo Box is populated with values from a different table.
The SetFilter macro is triggered using the AfterUpdate event. When the macro fires, Access asks for a parameter, so I know it's not getting what it needs to complete the macro action. When I provide a value, the macro works fine and returns the appropriate subset of records. I think the problem might be in the WHERE clause of the SetFilter statement; here is what I have.
[ComboBox value on Form]=[Table1]![Field]
Could it possibly be anything to do with using a different table to source the Combo box?
View 2 Replies
View Related
Aug 15, 2014
I have a list box, List3, in a form, which is populated from a query. The list populates correctly.I added a command button which I want to open a new edit form with the selected record from the List3 control.I used this code on the DoubleClick event - it opens the form EditEquipment, but the form does not have the relevant record, ItemID, open in it. It's an autonumber field and primary key. Is there something I now need to do in the EditEquipment OnLoad event or something like that?
Private Sub Command5_DblClick(Cancel As Integer)
If Len(Me.List3 & "") > 0 Then
DoCmd.OpenForm "EditEquipment", acNormal, , _
"[ItemID] = '" & Me.List3 & "'"
End If
End Sub
View 10 Replies
View Related
Aug 31, 2013
i want to see the product image in my database as per my selection from listbox in "frm_MainForm" but it shows error no 2220. database file is attached.
It does show the image when i add it to the form "frm_PruductMaster" and search in "frm_MainForm" but only until i restart application. after restarting application it again shows error 2220. But it shows image name in the error. (i have tried with .bmp and .jpg as well).
View 11 Replies
View Related
Oct 8, 2014
I am trying to resolve a problem with selecting multiple records.
I have a table called T_user and bound form called F_user.
This form displays all 3 fields from that table.
When I want to add a new user, I enter a name and select a department.
Some of the users work for few departments, so here is the question:
How to select multiple departments for one user?
The department field in F_user is set to LISTBOX, and the multi select option in properties is set to SIMPLE.
I can select multiple departments, but as we know it won't save in the table, it will leave it as NULL value.
How can I save the record then? In another form I need to select users from specific department, so lets say A.Smith, need to be visible in those few selected ones.
I have seen this [URL] .....
form this post [URL] .......
but unsure how can I make it work on my form.
View 5 Replies
View Related
Jun 21, 2013
I've created a database to track training courses. I'm having issues with selecting multiple trainers. I set up my table to lookup a "List" on the trainer column. I've entered 2 records into my form and it displays 6 records. See attach image.
View 3 Replies
View Related
Jul 29, 2014
In my subform, I have a field named Container Type (I know you don't need to tell me about Reserve names for Access, but I can't change the names) where when you choose one of the values (a combo box), the values for a second field (Container Code) changes (another combo box) based on the first selection. Then, based on the selection from the second field five other fields are automatically filled in.
Using:
Access 2010
Windows 7
View 14 Replies
View Related
Sep 12, 2013
I have a form that filter records off of combo, I want the user to run reports based off of the filter selected in the combo box.Here's the code I've been toying around with:
Code:
Private Sub ReQuote_Click()
Dim strCustomer As String
Dim Filter As String
If IsNull(Me![cboFilter]) Then Exit Sub
[code]....
I ripped it off of another thread on here but my needs are slightly different so I couldn't quite get it to do what I wanted.
View 6 Replies
View Related