Creating a Form in Microsoft Access with VBA
I need help in creating a form that can query a database and generate reports in access. For eg: 开发者_开发知识库if I want to know what type of products that were sold in year 2010, I will select the type of product from a "product combo box" and then will select the 2010 month from "month combo box". After clicking OK or RUN it would give me a list of all products for that month. It is possible to create such query form in access with the help of VBA? I would really appreciate your advice.
Thanks a lot.
Dim ssql as String
ssql = "SELECT * FROM your_table WHERE [Month]=" & Me.cboMonth & " AND [Prod]=" & Me.cboProd
DoCmd.OpenReport "Sales Report",,,,,,,ssql
http://msdn.microsoft.com/en-us/library/bb238032%28v=office.12%29.aspx
you may need if statement for checking how many parameter user select (checkboxs).
精彩评论