Link to home
Start Free TrialLog in
Avatar of JMBrooks
JMBrooks

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JMBrooks
JMBrooks

ASKER

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.
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.
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).
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.
See previous comment.
Oops, I didnt' get the comment about the actual solution into the correct location for the Jeffery Coachman suggestion.  500 more points!
ok

Glad I could help.

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

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

JeffCoachman