I am creating a form to view certain data summaries of my database. I have started out with the form having controls where the user specifies 4 values. These 4 values are then used to create a query when the user presses a button. So far the data is only retrieved from a query called "Item_Query", but I want to be able to retrieve data from any table or query. The query that is generated with the user input should be made the recordsource for the subform and the data should be displayed in the subform. The subform starts out without a recordsource. I have the part where I create the query:
Now I'm not sure how I should handle the controls on the subform. I want to view the subform as a datasheet. The data summaries I want to display have 2 or 3 columns and usually have a calculated field.
How should I generate the text boxes to display the data from code? And how do I get each of them the proper control source?
Code:
Private Sub cmdShow_Click()
Dim strQuery, strTime, strReFoRe, strWarranty As String
strTime = "((Item_Query.ReceivedDate) Between #" & txtDateFrom & "# And #" & txtDateTo & "#)"
Select Case frmReFoRe
Case 1
strReFoRe = ""
Case 2
strReFoRe = " AND ((Item_Query.ReFoReName)='" & cboReFoReName.Column(1) & "')"
End Select
Select Case frmWarranty
Case 1
strWarranty = ""
Case 2
strWarranty = " AND ((Item_Query.Warranty)= False)"
Case 3
strWarranty = " AND ((Item_Query.Warranty)= True)"
End Select
strQuery = "SELECT Item_Query.ManufacturerName, Count(Item_Query.ItemID) AS Items FROM Item_Query " & _
"WHERE (" & strTime & strReFoRe & strWarranty & ") " & _
"GROUP BY Item_Query.ManufacturerName;"
Me.RepQ_items_per_manufacturer_subform.Form.RecordSource = strQuery
Me.RepQ_items_per_manufacturer_subform.Requery
End Sub
Now I'm not sure how I should handle the controls on the subform. I want to view the subform as a datasheet. The data summaries I want to display have 2 or 3 columns and usually have a calculated field.
How should I generate the text boxes to display the data from code? And how do I get each of them the proper control source?