Hi, i have a sub form, which shows invoices for a particular customer, there is an "xselect" on the subform so the user can select what records they want to delete etc. Ive created a bit of code that sums the total amount of all of the invoices selected, and am trying to use a record set to put it into a txt box on the main form, but i cant work out why its not working. The code looks like this:
Private Sub chkXSelect_Click()
Dim Totalsql As String
Dim db As Database
Dim rst As DAO.Recordset
Totalsql = "SELECT Sum(tblPurchaseInvoice.Amount) AS SumOfAmount FROM tblPurchaseInvoice " _
& "HAVING (((tblPurchaseInvoice.Supplier)=1) AND ((tblPurchaseInvoice.XSelect)=True));"
'Debug.Print Totalsql
Set db = CurrentDb
Set rst = db.OpenRecordset(Totalsql)
txtSelectedTotal = rst.Fields("SumOfAmount"
rst.Close
Set rst = Nothing
End Sub
txtSelectedtotal is on the main form, but it just doesnt update, any ideas?
Thanks, Elliot.
Private Sub chkXSelect_Click()
Dim Totalsql As String
Dim db As Database
Dim rst As DAO.Recordset
Totalsql = "SELECT Sum(tblPurchaseInvoice.Amount) AS SumOfAmount FROM tblPurchaseInvoice " _
& "HAVING (((tblPurchaseInvoice.Supplier)=1) AND ((tblPurchaseInvoice.XSelect)=True));"
'Debug.Print Totalsql
Set db = CurrentDb
Set rst = db.OpenRecordset(Totalsql)
txtSelectedTotal = rst.Fields("SumOfAmount"
rst.Close
Set rst = Nothing
End Sub
txtSelectedtotal is on the main form, but it just doesnt update, any ideas?
Thanks, Elliot.