querydef error 3126

MSAccess 2003:  A query that picks up a date from an open form suddenly comes up with the error message "3126: Invalid bracketing of name '[forms!frmreports!frmTodate]'."  I replaced the query with a copy from an old application.  It ran ok. A few hours later the error is being reported again.  It happened on my machine with 2 versions of the application and on the user copy of the app.
Here is the bare code:
  Set qdf = CurrentDb.QueryDefs(strQuery)
  For intI = 0 To qdf.Parameters.Count - 1
    Set prm = qdf.Parameters(intI)
    prm.Value = Eval(prm.Name) 'evaluate the parameter name
  Next intI
The parameter strQuery returns the 3126 error message.

Any idea what is causing the instability?
Thank you
Michael Brooks
Maintainer of legacy MSworks
JMBrooksAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jeffrey CoachmanMIS LiasonCommented:
Try it like this:

Forms![frmreports]![frmTodate]

And let's be clear, ...a form reference will typically point to a control.
Forms![YourForm]![YourControl]
...It looks like you are pointing to a subform,(frmTodate) ...so it is hard to see how this is being used in a query?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JMBrooksAuthor Commented:
Thank you for the possible syntax solution.
The control is [forms!frmreports!frmTodate]: frmTodate is a text control on the frmReports referenced from the Forms collection.

I will try this, and get back.
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
I replaced the query with a copy from an old application.  It ran ok. A few hours later the error is being reported again.
This concerns me - if you have an application that works now, but does NOT work in a couple of hours, you'd have to suspect either (a) trouble with the application/host or (b) trouble with the environment.

For (a), I'd first do a Compact/Repair on the database (after making a backup). If that doesn't work, try a Decompile. To do that, create a Shortcut with this as the Target:

"full path to msaccess.exe" "full path to the database" /decompile

Run that, then Compact again.

Also Compile the application - from the VBA Editor click Debug - Compile. Fix any errors, and continue doing this until the Compile option is disabled.

After compiling, Compact again.

For (b), make sure you're fully updated Windows/Office with any required service packs and/or hotfixes.

Also be sure that you're running in a compliant environment, which means a split architecture (BackEnd with tables only, FrontEnd with everything else) with each user having their own non-shared copy of the FE.
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

JMBrooksAuthor Commented:
Thank you for the suggestions.  It's intriguing that it happened on two copies of the application on my desktop and on the copy used by the company.  There are no compile errors, repair and compact are the first things I try.  I've never seen the 'decompile' technique.  From the prior comment, I did find a difference in the references between the parameter statement and the in-line field statement (missing sq brackets).
JMBrooksAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for JMBrooks's comment #a40979097

for the following reason:

Thank you for suggesting the error was in the object referencing.  The parameter statment and the query statement referencing the control on the form were not identical.  When I changed [forms!frmReports!frmToDate] to [Forms]![frmReports]![frmTodate] I have had no querydef errors.
Also please pardon my excreable thoughtlessness is naming a text control with a 'frm' prefix.  Don't know what I was thinking a very long time ago.
JMBrooksAuthor Commented:
See previous comment.
JMBrooksAuthor Commented:
Oops, I didnt' get the comment about the actual solution into the correct location for the Jeffery Coachman suggestion.  500 more points!
Jeffrey CoachmanMIS LiasonCommented:
ok

Glad I could help.

BTW, you can use the "Expression Builder" to build your references.
Either use the expression builder button:
Build Button...Or use the Hotkey combination:
   Ctrl+F2

Using the dialog box to build your expressions will minimize the chances of a syntax error.

JeffCoachman
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.