please check the syntax of this query

A

access user

In the default value of a field in a table I entered

SELECT Count(*) FROM (qselUserHitsTotal);

basically, I want to populate the field with the value returned by that
query, BUT, I get the following error

"The Syntax of the subquery in this expression is incorrect. Check the
subquery's syntax and enclose the subquery in parentheses."

Please advise what I've done wrong.
TIA
 
J

John Vinson

In the default value of a field in a table I entered

SELECT Count(*) FROM (qselUserHitsTotal);

basically, I want to populate the field with the value returned by that
query, BUT, I get the following error

"The Syntax of the subquery in this expression is incorrect. Check the
subquery's syntax and enclose the subquery in parentheses."

Please advise what I've done wrong.

Attempting to store a derived value into a table field AT ALL is
generally incorrect. A Table DefaultValue field cannot reference a
query, any other table, nor a user defined function.

It's almost always best to just recalculate counts, sums, and such
dynamically as needed rather than storing them in a table at all. If
you have a REAL need to capture the value of qselUserHitsTotal as of a
specific point in time (realizing that the stored value will be WRONG
if the underlying query changes), you'll need to use code in the
BeforeInsert event of the Form being used to update the table to
capture this value, rather than the DefaultValue in the table.

John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top