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!frmToda te]'." 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(strQue ry)
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
Here is the bare code:
Set qdf = CurrentDb.QueryDefs(strQue
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
ASKER
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).
ASKER
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!frmToDat e] to [Forms]![frmReports]![frmT odate] 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.
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!frmToDat
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.
ASKER
See previous comment.
ASKER
Oops, I didnt' get the comment about the actual solution into the correct location for the Jeffery Coachman suggestion. 500 more points!
ASKER
The control is [forms!frmreports!frmTodat
I will try this, and get back.