Yes, thank you, dear DHookomCan you provide your database with the Hall field (and possibly teacher) added?
Yes exactlyYou don't have a Hall field or table but you apparently want to select an individual hall for the filter. I need enlightening.
I added it to the class table. You have sent the database fileWhy don't you add the field so you can use it?
Please send a new file. I don't know which table you added the field to. I would have expected a hall to include multiple classrooms but it seems your situation is the opposite.
Thank you, dear,LarryEIf you are going to use halls, then they need to be linked to the class table and the supply quantities table. And if you wish to view the data in crosstab format, then you can just add it to the forms footer section. See attached file as an example of how input and viewing crosstab can be done.
ACCESS will not filter a crosstab query based upon criteria in a form. You must filter a crosstab query using its own filtering dropdown criteria for each field.Thank you, dear,LarryE
for your help. But this is not what I want.
What I want is when I select the class the combo box does a filter for the crosstab query. See my comment in
For example, during the year I will provide the class (A1) with stationery every week or two. This class will repeat that it received stationery and other things. At the end of the year or during a certain period, I will go to the combo box and choose the name of the classroom or the name of the teacher, for example. The combo box will filter the table or crosstab query and tell me that this class or teacher received materials and pens at certain intervals, perhaps more than other classes, or that this teacher received and consumed more materials than his fellow teachers.
May I ask why? You can change the sql of the query and reload it.ACCESS will not filter a crosstab query based upon criteria in a form. You must filter a crosstab query using its own filtering dropdown criteria for each field.
Private Property Get sql() As String
sql = "SELECT DISTINCTROW q.ClassroomID, c.ClassroomName, q.SupplyID, s.SupplyName, q.Quantity "
sql = sql & "FROM Supply AS s INNER JOIN (Classroom AS c INNER JOIN SuppyQuantity AS q ON c.ClassroomID = q.ClassroomID) "
sql = sql & "ON s.SupplyID = q.SupplyID"
End Property
Private Property Get sort() As String
sort = "ORDER BY q.ClassroomID, q.SupplyID;"
End Property
Private Sub combx_AfterUpdate()
Dim Filtr As String
If Not combx & "" = "" And cboQuery = "QryInput_Crosstab" Then
Filtr = "WHERE ClassRoomname='" & combx & "'"
End If
CurrentDb.QueryDefs("Qryinput").sql = sql & " " & Filtr & " " & sort
Me.sfrmQuery.Form.Requery
End Sub
Private Sub Form_Close()
CurrentDb.QueryDefs("Qryinput").sql = sql & " " & sort
End Sub
This is amazing . Thank you KitaYama@LarryE
I have a non-English version of Access and most of the time, others can not open my files.
If the above file shows error, Download OP's file in #22, and add the following to frmDisplayQuery.
Then check if form's on-close event and combx's after-update event are set to :"[Event Procedure]"
SQL:Private Property Get sql() As String Dim sq As String sql = "SELECT DISTINCTROW q.ClassroomID, c.ClassroomName, q.SupplyID, s.SupplyName, q.Quantity " sql = sql & "FROM Supply AS s INNER JOIN (Classroom AS c INNER JOIN SuppyQuantity AS q ON c.ClassroomID = q.ClassroomID) " sql = sql & "ON s.SupplyID = q.SupplyID" End Property Private Property Get sort() As String sort = "ORDER BY q.ClassroomID, q.SupplyID;" End Property Private Sub combx_AfterUpdate() Dim Filtr As String If Not combx & "" = "" And cboQuery = "QryInput_Crosstab" Then Filtr = "WHERE ClassRoomname='" & combx & "'" End If CurrentDb.QueryDefs("Qryinput").sql = sql & " " & Filtr & " " & sort Me.sfrmQuery.Form.Requery ' Me.sfrmQuery.SourceObject = "Query." & Me.cboQuery & "" End Sub Private Sub Form_Close() CurrentDb.QueryDefs("Qryinput").sql = sql & " " & sort End Sub
You can add a select statement and do the same concept for other queries too.This is amazing . Thank you KitaYama
This is what I really aspire to. Thank you again. Nice work. When you clear the contents of the filter's combo box and click the Enter button, all the chapters reappear. There is no need to close and open the form again. Thank you dear.
Thank you, my friend.KitaYamaYou can add a select statement and do the same concept for other queries too.
Thanks for the reply dearGaP42It makes no real sense to create another table for materials that are not stationery. Simply add a field that allows the materials in the Supply table to be categorised as Stationery, Presentation Equipment, Other etc. (Maintain it as a SupplyCategory table). This is a standard practise in database design referred to as normalisation. The query(ies) can use the Category to filter the list limiting the number of records to display for when interested in Stationery or Equipment as needed.
I don't understand your database and how it should work, so I can't advise on your table structure. Others, are much better than me in this area. You may want to listen to them. I only can say that your above points, aren't reasonable for adding a new table. You can always have several queries to limit fields and rows, and use them in different situation. Instead of trying to figure out how you need a form to be shown or work, you should first work on a correct table structure and relation.The purpose of this is, firstly, so that the query display in the form is not long and does not have to use the horizontal scroll bar, and secondly, that these materials are not included in the stationery.
PARAMETERS [Forms]![frmDisplayQuery]![combx] Text ( 255 );
TRANSFORM Sum(SuppyQuantity.Quantity) AS SumOfQuantity
SELECT Classroom.TeacherName, Classroom.ClassroomName, Sum(SuppyQuantity.Quantity) AS [Total Of Quantity]
...