Query error 3061

mveijndh

Registered User.
Local time
Today, 13:46
Joined
Dec 17, 2011
Messages
113
I'm trying to retrieve a value from a query and put this on a form.
In order to do so I've build a query that provides me with the correct data. When I put the query to work in VBA it provides me with error 3061, to few parameters.

Code:
strSQL1 = "SELECT DISTINCT TOP 1 [TotalExpenses]+[InvoiceDefaultHire]+[WorkDays]*[InvoiceDefaultEmpCost] AS TotalInvoiceValue, " & _
"queExpSum.TotalExpenses, queInvoiceWorkDays.WorkDays, tblInvoice.InvoiceDefaultHire, tblInvoice.InvoiceDefaultEmpCost, " & _
"[WorkDays]*[tblInvoice]![InvoiceDefaultEmpCost] AS InvoiceWorkCost FROM tblInvoice, queExpSum, queInvoiceWorkDays;"
 
Set dbs = CurrentDb
Set rstInvoiceTotal = dbs.OpenRecordset(strSQL1)
If Not (rstInvoiceTotal.BOF And rstInvoiceTotal.EOF) Then
    rstInvoiceTotal.MoveFirst
    Me!InvoiceValue.Value = rstInvoiceTotal!TotalInvoiceValue
End If

Any clues?
 
I suggest putting this back in the query builder, get it working, and then save it. Let's say your name it qryTotalInvoiceValue. Then replace the code you got with;
Code:
Me.Invoice = DLookUp("[TotalInvoiceValue]", "[qryTotalInvoiceValue]")

Note that for controls like text boxes and combo box their name is sufficient, i.e., Me.Invoice.Value is the same as Me.Invoice
 
Also check if any of subqueries (queExpSum, queInvoiceWorkDays) doesn't require parameter.
 

Users who are viewing this thread

Back
Top Bottom