run-time error '3464' - Data Type Mismatch

weavind

Registered User.
Local time
Today, 09:18
Joined
Feb 9, 2010
Messages
15
Hi,

I am trying to sum up a list of invoiced items (data stored in table tblInvoiceDetail) and write this value to the “Total” field in the table tblInvoices. I want this to update after each record is typed in the subform. I was given the below code from friend, but neither of us can get it working. Everytime we change a value in the subform, we get the error “Run-time error ‘3464’; Data type mismatch in critical expression”. Any idea of where I am going wrong? Or can you give me code that I can use?



Private Sub Form_AfterUpdate()
Set db = CurrentDb
Set rst = db.OpenRecordset("SELECT tblInvoiceDetail.INoID, Sum(tblInvoiceDetail.Total) as SumOfTotal FROM tblInvoiceDetail GROUP BY tblInvoiceDetail.INoID HAVING (((tblInvoiceDetail.INoID)='" & Form_frmInvoices.INoID & "'));")
Form_frmInvoices.txtTotal = rst!SumOfTotal
End Sub


 
try

Me.txtTotal = CCur(rst!SumOfTotal)

however you first need to check for EOF

Then after you need to close the rst and set to Nothing

Hopefully this was just a snippet of your code and you catered for this.
 

Users who are viewing this thread

Back
Top Bottom