I am using the following code to return the Mode of a data selection:
Dim StrSQL As String
StrSQL = "SELECT TOP 1 tblOEOrderDetail.discount_pct FROM tblOEOrderDetail " & _
"GROUP BY tblOEOrderDetail.OrderHeaderID, tblOEOrderDetail.discount_pct " & _
"HAVING (((tblOEOrderDetail.OrderHeaderID) = " & Forms!frmOrderHeaderEntry!OrderHeaderIDTxt & ")) " & _
"ORDER BY Count(tblOEOrderDetail.discount_pct) DESC"
I want to store the result in the field of a record I am adding to an existing table. How do I do this?
I simply tried:
[fieldname]= DoCmd.RunSQL StrSQL
but I get a syntax error.