The database is CHEF_HELPER1.MDB
The month table name is month
The sales table is housesales
I have code that will sum the sales in housesales, but I want to sum it by the month in text1.text. So if January is in text2.text, it will sum all the sales in housesales where January is the month. The same for the rest of the months.
I will use the code for two tables in two separate command buttons.
one for table housesales, and the other for table bar_sales.
Code listed below is for bar_sales.
I also would like the text1.text formatted as "#########.00"
Could some kind soul please help me with the code?
What I have now which works is the following.
Expand|Select|Wrap|Line Numbers
- Dim MyCon As New ADODB.Connection
- Dim housesales As New ADODB.Recordset
- Dim sConnect As String
- Dim food_sales
- food_sales = Format("#########.00")
- text2.Text = Format$("#########.00") 'Format$(formula2, "#,###,000.00")
- sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
- "Data Source=" & _
- App.Path & "\CHEF_HELPER1.MDB"
- MyCon.Open sConnect
- housesales.Open "select sum(food_sales) from housesales", MyCon, adOpenDynamic, adLockPessimistic
- text2.Text = housesales.Fields(0)
- housesales.Close
- MyCon.Close
It sums all the data in table bar_sales successfully.
Thank you.
Kevin