Forum Discussion

Dave_Williams1200's avatar
Dave_Williams1200
Copper Contributor
Sep 27, 2022

MS Access error 2465 can't find field

I have novice/intermediate MS-Access/VBA programming skills. I'm working on a project for a federal agency. Because of the proprietary nature of the project, I cannot reveal details of either the database or the VBA code. So I will have to speak somewhat generically.

 

I built a database that has a form and a subform. Raw data from an Excel workbook is imported into a table. I wrote some VBA code to develop a key-word based query to populate the subform.

The customer wants to be able to refine the search by querying the results in the subform. I'm sure how to do that. I'm open to suggestions.

 

Meanwhile, one idea I have is to copy the subform records into a 'scratch' table using "Insert Into" and query that table.

 

Note: All of these are "Dimmed" as String

Id = Me.TableData.Form.RecordsetClone.Id
Category = Me.TableData.Form.RecordsetClone.Category
Element1 = Me.TableData.Form.RecordsetClone.Element1
Element2 = Me.TableData.Form.RecordsetClone.Element2
Required_Information = Me.TableData.Form.RecordsetClone.[Required Information]
Information_Detail = Me.TableData.Form.RecordsetClone.[Information Detail]
Information_Source = Me.TableData.Form.RecordsetClone.[Information Source]
Element3 = Me.TableData.Form.RecordsetClone.Element3
Data_Path = Me.TableData.Form.RecordsetClone.[Data Path]

Insert_Into, The_Values, and Sql_Table are dimmed as String

 

Insert_Into = Insert_Into & " INSERT INTO Scratch1_Tbl( ID, Category, Element1, Element2, [Required Information], [Information Detail], " _ 
& " [Information Source], Element3, [Data Path] ) "

The_Values = The_Values _
& " VALUES ( !id, !Category, !Element1, !Element2, !Required_Information, !Information_Detail, !Information_Source, !Element3, !Data_Path ); "

SQL_Table = SQL_Table & Insert_Into & The_Values

DoCmd.RunSQL SQL_Table


I get the following error:

Run-time error '2465:
Microsoft Access can't find the field 'Data_Path' referred to in your expression.

 

I don't understand why it cannot find Data_Path. If I hard code a value for Data_path then it complains that it cannot find Element3. It seems to be a problem with the last item in the values list.

No RepliesBe the first to reply