Sorry for late reply. Looking back over my code i realised I had not even written the VBA code completely. The control source code for the text box is written into the control source box below to give the user a default value
Code:
=Nz(DSum("[Amount]","Expenses","[Expense Type]=1 And [InvoiceDate]>=DateSerial(Year(Date()), 1, 1)"),0)
The user can then use combo boxes to set the start and end month and year. I check for input errors and then I want to change the control source to display the total value between the two dates. Here is where I run into problems. This is the VBA I've been messing with to try and change the control source but I'm stuck now.
Code:
Me.txtTotalAdvertising.ControlSource = "Nz(DSum("[Amount]", "Expenses", "[Expense Type]=1 And [InvoiceDate]>=" _
& Me.txtExpensesStartDate.text & "[InvoiceDate]<=" & Me.txtExpensesEndDate.text & ")""
This throws an error about brackets which I'm working on but I'm not sure if this will actually produce the desired result or if it is possible to change the control source like this.