I have constructed a select query in VBA as follows:
[Counter]
counter
Basically, what I need is to count the number of occurrences of "plate" in the preorderdet_type field for a specific invoice number (which I manage to pass to the query using the variable [var_invoice_number]).
My problem is that I cannot return the count back to variable counter which you see I've used "&" to make it stand out of the SQL string.
The value I get is 0 and I notice when I look at the query in design view, the field is renamed to "0". It seems I'm catching the field name instead of the value.
Any suggestions?
Thanx "All is not as it seems"
Code:
Dim invcounttypeqdf As QueryDef
strSQL = "SELECT [PreOrders details].preorderdet_invoice_no, [PreOrders details].preorderdet_type, Count([PreOrders details].preorderdet_type) AS " &
Code:
& " " _
& "FROM [PreOrders details] " _
& "GROUP BY [PreOrders details].preorderdet_invoice_no, [PreOrders details].preorderdet_type " _
& "HAVING ((([PreOrders details].preorderdet_invoice_no)=" & [var_invoice_number] & ") AND (([PreOrders details].preorderdet_type)=""PLATE""));"
Set invcounttypeqdf = dbs.CreateQueryDef("invcounttypeqry", strSQL)
DoCmd.OpenQuery "invcounttypeqry"
msgbox
Code:
DoCmd.Close acQuery, "invcounttypeqry"
Basically, what I need is to count the number of occurrences of "plate" in the preorderdet_type field for a specific invoice number (which I manage to pass to the query using the variable [var_invoice_number]).
My problem is that I cannot return the count back to variable counter which you see I've used "&" to make it stand out of the SQL string.
The value I get is 0 and I notice when I look at the query in design view, the field is renamed to "0". It seems I'm catching the field name instead of the value.
Any suggestions?
Thanx "All is not as it seems"