472,141 Members | 1,594 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,141 software developers and data experts.

error; [2465] Mircosoft Access cant find the field '|" referred to in your expression

133 100+
the following code is generating an error; [2465] Mircosoft Access cant find the field '|" referred to in your expression"

any suggestions would be appreciated.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Expire_Date_Qry_Parameter_AfterUpdate()
  2.   On Error GoTo Err_Hndlr
  3.  
  4.     Forms!F_Contract_Mgt_Entry!Expire_Date_Temp_Parameter = Forms!F_Contract_Mgt_Entry!Expire_Date_Qry_Parameter
  5.     DoCmd.OutputTo acOutputQuery, stDocName, [Excel 97 - Excel 2003 Workbook (*.xls)], AutoStart
  6.  
  7.    MsgBox "Task Complete!"
  8.  
  9.  
  10. Exit_Expire_Date_Qry_Parameter_AfterUpdate:
  11.     Exit Sub
  12.  
  13. Err_Hndlr:
  14.     MsgBox "[" & Err.Number & "]:  " & Err.Description, vbInformation, "Expire_Date_Qry_Parameter_AfterUpdate()"
  15. End Sub
  16.  
May 14 '10 #1

✓ answered by dowlingm815

Got it...the solution the error code is the syntax for the output...the code should be:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OutputTo acQuery, stDocName, "MicrosoftExcelBiff8(*.xls)", "", True, "", 0
** Edit **
The explanation is that quotes are needed around the format parameter. Changing the value of the parameter (as shown here) was not relevant.

11 4292
Jim Doherty
897 Expert 512MB
@dowlingm815
There is nothing in your code to suggest what stDocName is.
Is the query that presumably is stDocName getting its value from the form control Expire_Date_Temp_Parameter? If so what does the query syntax say?
May 14 '10 #2
dowlingm815
133 100+
stDocName is a global variable. Depending the client's response, stDocName receives a Query Export, as in this case, or Report Preview. The Query receives date parameters from the form.

unfortunately, i don't have access to the code until monday.
May 15 '10 #3
NeoPa
32,498 Expert Mod 16PB
Posting the full error message is helpful. Identifying the line the error occurred on would be even more helpful. I guess it's probably line #5, but confirmation would be good.
May 15 '10 #4
NeoPa
32,498 Expert Mod 16PB
If this is indeed the case then I expect the problem is within your query rather than the VBA code.

What happens when you try running the query normally (to show on screen) at the point this crashes (I'm talking about suspending the code to do the test)?
May 15 '10 #5
dowlingm815
133 100+
the non-vba query has a field name "ExpirationDate" that will receive the value from the form's field. the criteria is "<[Forms]![F_Contract_Mgt_Entry]![Expire_Date_Qry_Parameter]"

everything looks fine to me. funny thing is the query is called twice with two separate conditions. the first condition generates a report, the other condition, this condition, generates a query to be exported.
May 17 '10 #6
NeoPa
32,498 Expert Mod 16PB
Could you explain that second paragraph. I couldn't work out what you were trying to say.

If it helps, drop the relevant code in.
May 18 '10 #7
dowlingm815
133 100+
The application has a screen that offers three choices. When the second or third choice is selected, the event procedure kicks off a query that receives a date field from the screen. there are two different date fields to coordinate with the user's selection.

the code has a temp field that receives the date value and passes it to a query. when the second choice is selected, the query runs without errors. when the third choice is selected, the following error code is generated:

[2465] Mircosoft Access cant find the field '|" referred to in your expression"

when the query has the parameter removed, no error is generated. again, what is brothersome, it basically runs the same code for the second selection, and generates an error on the third run.

the entire code is as follows:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Option Compare Database
  3.  
  4.  
  5. Private Sub Contract_Mgt_Rpt_by_Contract_Status_Click()
  6.  
  7. On Error GoTo Err_Hndlr
  8.  
  9.  
  10.     Forms!F_Contract_Mgt_Entry!Expire_Date_Temp_Parameter = Null
  11.     Forms!F_Contract_Mgt_Entry!Expire_Date_Qry_Parameter = Null
  12.     Forms!F_Contract_Mgt_Entry!Expire_Date_Rpt_Parameter = Null
  13.     Forms!F_Contract_Mgt_Entry!Expire_Date_Rpt_Parameter.Visible = True
  14.     Forms!F_Contract_Mgt_Entry!Expire_Date_Qry_Parameter.Visible = False
  15.     stDocName = "R_Contract_Status"
  16.  
  17.  
  18. Exit_Contract_Mgt_Rpt_by_Contract_Status_Click:
  19.     Exit Sub
  20.  
  21. Err_Hndlr:
  22.     MsgBox "[" & Err.Number & "]:  " & Err.Description, vbInformation, "Contract_Mgt_Rpt_by_Contract_Status_Click()"
  23.  
  24. End Sub
  25.  
  26. Private Sub Expire_Date_Rpt_Parameter_AfterUpdate()
  27.  
  28. On Error GoTo Err_Hndlr
  29.  
  30.  
  31.     Forms!F_Contract_Mgt_Entry!Expire_Date_Temp_Parameter = Forms!F_Contract_Mgt_Entry!Expire_Date_Rpt_Parameter
  32.     DoCmd.OpenReport stDocName, acPreview
  33.  
  34.  
  35. Exit_Expire_Date_Rpt_Parameter_AfterUpdate:
  36.     Exit Sub
  37.  
  38. Err_Hndlr:
  39.     MsgBox "[" & Err.Number & "]:  " & Err.Description, vbInformation, "Expire_Date_Rpt_Parameter_AfterUpdate()"
  40. End Sub
  41.  
  42. Private Sub Expire_Date_Rpt_Parameter_Enter()
  43.  On Error GoTo Err_Hndlr
  44.  
  45.  Forms!F_Contract_Mgt_Entry!Expire_Date_Rpt_Parameter = Null
  46.  
  47. Exit_Expire_Date_Rpt_Parameter_Enter:
  48.     Exit Sub
  49.  
  50. Err_Hndlr:
  51.     MsgBox "[" & Err.Number & "]:  " & Err.Description, vbInformation, "Expire_Date_Rpt_Parameter_Enter()"
  52.  
  53. End Sub
  54.  
  55. Private Sub Expire_Date_Qry_Parameter_AfterUpdate()
  56.   On Error GoTo Err_Hndlr
  57.  
  58.     Forms!F_Contract_Mgt_Entry!Expire_Date_Temp_Parameter = Forms!F_Contract_Mgt_Entry!Expire_Date_Qry_Parameter
  59.     DoCmd.OutputTo acOutputQuery, stDocName, [Excel 97 - Excel 2003 Workbook (*.xls)], AutoStart
  60.  
  61.    MsgBox "Task Complete!"
  62.  
  63.  
  64. Exit_Expire_Date_Qry_Parameter_AfterUpdate:
  65.     Exit Sub
  66.  
  67. Err_Hndlr:
  68.     MsgBox "[" & Err.Number & "]:  " & Err.Description, vbInformation, "Expire_Date_Qry_Parameter_AfterUpdate()"
  69. End Sub
  70.  
  71. Private Sub Expire_Date_Qry_Parameter_Enter()
  72.  On Error GoTo Err_Hndlr
  73.  
  74.  Forms!F_Contract_Mgt_Entry!Expire_Date_Rpt_Parameter = Null
  75.  
  76. Exit_Expire_Date_Qry_Parameter_Enter:
  77.     Exit Sub
  78.  
  79. Err_Hndlr:
  80.     MsgBox "[" & Err.Number & "]:  " & Err.Description, vbInformation, "Expire_Date_Qry_Parameter_Enter()"
  81. End Sub
  82.  
  83. Private Sub ExportContractData_Click()
  84.  
  85.  On Error GoTo Err_Hndlr
  86.  
  87.  Forms!F_Contract_Mgt_Entry!Expire_Date_Temp_Parameter = Null
  88.  Forms!F_Contract_Mgt_Entry!Expire_Date_Qry_Parameter = Null
  89.     Forms!F_Contract_Mgt_Entry!Expire_Date_Rpt_Parameter.Visible = False
  90.     Forms!F_Contract_Mgt_Entry!Expire_Date_Qry_Parameter.Visible = True
  91.     stDocName = "Q_2_Recs_<_ExpireDateParameter"
  92.  
  93. Exit_ExportContractData_Click:
  94.     Exit Sub
  95.  
  96. Err_Hndlr:
  97.     MsgBox "[" & Err.Number & "]:  " & Err.Description, vbInformation, "ExportContractData_Click()"
  98. End Sub
  99.  
  100.  
  101.  
May 18 '10 #8
dowlingm815
133 100+
for some odd reason, i believe it is the following statement in the code:

Expand|Select|Wrap|Line Numbers
  1.  
  2.  DoCmd.OutputTo acOutputQuery, stDocName, [Excel 97 - Excel 2003 Workbook (*.xls)], AutoStart
  3.  
  4.  
May 18 '10 #9
dowlingm815
133 100+
Got it...the solution the error code is the syntax for the output...the code should be:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OutputTo acQuery, stDocName, "MicrosoftExcelBiff8(*.xls)", "", True, "", 0
** Edit **
The explanation is that quotes are needed around the format parameter. Changing the value of the parameter (as shown here) was not relevant.
May 18 '10 #10
dowlingm815
133 100+
case closed...
May 18 '10 #11
gershwyn
122 100+
@dowlingm815
You want quotes around the format parameter:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OutputTo acOutputQuery, stDocName, "Excel 97 - Excel 2003 Workbook (*.xls)", AutoStart
I don't know if that will fix everything or not, but I think Access is getting confused by the brackets.

EDIT: I was too slow, you solved it yourself. :)
May 18 '10 #12

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Bruce Skamser | last post: by
2 posts views Thread by zufie | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.