473,382 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Run-time error 2465 when opening subform

Lyn
Hi, this has been driving me nuts. I'm on Office 2003 SP1, Win XP SP1.

I am opening a form with a number of subforms based on various tables. The
subforms are populated via the main form's Current event. I am using
similar code to open each of the subforms successfully -- except for this
one case which gives the above error.

I have simplified the SQL to its most basic level. It runs just fine as a
query. I just can't make it work in VBA. Here is the code snippet:

mySQL = "SELECT * FROM MiscRecs" 'simplified
Me.[sfmEducation].Form.RecordSource = mySQL
Me.[sfmEducation].LinkMasterFields = ""
Me.[sfmEducation].LinkChildFields = ""

The subform is sfmEducation. It contains several fields bound to table
MiscRecs in tabular format. When the error occurs (opening the main form),
the second line of the above code is highlighted in debug mode.

The full error meesage is:

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

I had the '|' occur once before and I posted a query on it. Someone
answered but I have lost the reply. I think it meant that Office could not
identify the field (ie, '|' is a placeholder for the unidentified field).

I am sure that I am missing something very basic, but I'm hanged if I can
see it! All help greatly appreciated.

--
Cheers,
Lyn.
Nov 13 '05 #1
5 9830
Lyn wrote:
Hi, this has been driving me nuts. I'm on Office 2003 SP1, Win XP SP1.

I am opening a form with a number of subforms based on various tables. The
subforms are populated via the main form's Current event. I am using
similar code to open each of the subforms successfully -- except for this
one case which gives the above error.

I have simplified the SQL to its most basic level. It runs just fine as a
query. I just can't make it work in VBA. Here is the code snippet:

mySQL = "SELECT * FROM MiscRecs" 'simplified
Me.[sfmEducation].Form.RecordSource = mySQL
Me.[sfmEducation].LinkMasterFields = ""
Me.[sfmEducation].LinkChildFields = ""

I haven't tested or looked at the code but...
Me.LinkMasterFields = ""
Me.LinkChildFields = ""
would appear to make sense since you are attempting to sent the
relationship in the subform from the main form.
Nov 13 '05 #2
Lyn
Hi, thanks for the quick response.

The format "Me.<subform>.LinkChildFields = " is what was advised to me by
someone else in this group for a similar situation, and it certainly works
for all the other subforms in this main form for which I am using the same
type of coding. It is only since I have been trying to extend the form with
an additional subform that I have experienced this problem.

In any case, I don't think that the code is actually reaching these last two
statements. Debug mode always highlights the previous statement in yellow
(ie, "~RecordSource = mySQL"). Once this problem is resolved, I should be
able to see if the last two statements work or not. I will keep your advice
in mind.

Thanks again.

--
Cheers,
Lyn.

"Salad" <oi*@vinegar.com> wrote in message
news:2S*****************@newsread1.news.pas.earthl ink.net...
Lyn wrote:
Hi, this has been driving me nuts. I'm on Office 2003 SP1, Win XP SP1.

I am opening a form with a number of subforms based on various tables.
The subforms are populated via the main form's Current event. I am using
similar code to open each of the subforms successfully -- except for this
one case which gives the above error.

I have simplified the SQL to its most basic level. It runs just fine as
a query. I just can't make it work in VBA. Here is the code snippet:

mySQL = "SELECT * FROM MiscRecs" 'simplified
Me.[sfmEducation].Form.RecordSource = mySQL
Me.[sfmEducation].LinkMasterFields = ""
Me.[sfmEducation].LinkChildFields = ""

I haven't tested or looked at the code but...
Me.LinkMasterFields = ""
Me.LinkChildFields = ""
would appear to make sense since you are attempting to sent the
relationship in the subform from the main form.

Nov 13 '05 #3
Lyn wrote:
Hi, thanks for the quick response.

The format "Me.<subform>.LinkChildFields = " is what was advised to me by
someone else in this group for a similar situation, and it certainly works
for all the other subforms in this main form for which I am using the same
type of coding. It is only since I have been trying to extend the form with
an additional subform that I have experienced this problem.

In any case, I don't think that the code is actually reaching these last two
statements. Debug mode always highlights the previous statement in yellow
(ie, "~RecordSource = mySQL"). Once this problem is resolved, I should be
able to see if the last two statements work or not. I will keep your advice
in mind.

Thanks again.


Maybe you can try something. Put this code just before the current code
that blows up.

Dim s As String
s = Me.[sfmEducation].Form.RecordSource 'check my spelling of subform
MsgBox s

This should tell you what the current subform recordsource is. It you
get an error here, you know you are making an incorrect reference.

Since you supplied a simplified SQL string, also add this line.
Debug.Print mySQL

Now go to the debug window. Scan the line and see that it looks
correct. If it does, copy it to the clipboard then create a new query...
Queries/New/Design/(click close on AddTables), and from the menu select
Edit/SQL or View/SQL and paste the line from the debug window. It will
either run or blow up. If it blows up, you should be able to determine
what the error is.

Nov 13 '05 #4
Lyn
Thanks for the follow-up. I had already tried the "debug.print mySQL" which
produced normal-looking SQL, and I had also tried plugging this into a query
and running it (as per the original post). All of this worked OK, even with
the original SQL (ie, before simplification).

Inserting the string "s" as per your suggestion did not display the Record
Source, because the same '2465' error occurred again, this time with the
debug highlight on the "s = Me. ..." statement.

However, your suggestion did help me find the cause of the problem and
enabled me to fix it at last! When I was typing in your code, I got as far
as:

s = Me.sfm

At that point, the interactive help system displayed a list of all objects
starting with "sfm" -- and I noticed that "sfmEducation" was not there! So
I went back to the subform properties and compared with the other subforms.
The difference was immediately obvious.

When you select the "All" tab, the top two properties are:

Name
Source Object

In all the other subforms, both values were the same (ie, "sfmSubFormName").
But for sfmEducation, Name was set incorrectly to the Caption text
("Education History") and Source Object to "sfmEducation". Setting both to
"sfmEducation" resolved the problem.

I knew it would be something simple and silly in the end -- and it was!
Thanks again for your help.

--
Cheers,
Lyn.

"Salad" <oi*@vinegar.com> wrote in message
news:yf*****************@newsread1.news.pas.earthl ink.net...
Lyn wrote:
Hi, thanks for the quick response.

The format "Me.<subform>.LinkChildFields = " is what was advised to me by
someone else in this group for a similar situation, and it certainly
works for all the other subforms in this main form for which I am using
the same type of coding. It is only since I have been trying to extend
the form with an additional subform that I have experienced this problem.

In any case, I don't think that the code is actually reaching these last
two statements. Debug mode always highlights the previous statement in
yellow (ie, "~RecordSource = mySQL"). Once this problem is resolved, I
should be able to see if the last two statements work or not. I will
keep your advice in mind.

Thanks again.


Maybe you can try something. Put this code just before the current code
that blows up.

Dim s As String
s = Me.[sfmEducation].Form.RecordSource 'check my spelling of subform
MsgBox s

This should tell you what the current subform recordsource is. It you get
an error here, you know you are making an incorrect reference.

Since you supplied a simplified SQL string, also add this line.
Debug.Print mySQL

Now go to the debug window. Scan the line and see that it looks correct.
If it does, copy it to the clipboard then create a new query...
Queries/New/Design/(click close on AddTables), and from the menu select
Edit/SQL or View/SQL and paste the line from the debug window. It will
either run or blow up. If it blows up, you should be able to determine
what the error is.

Nov 13 '05 #5
Lyn wrote:
I knew it would be something simple and silly in the end -- and it was!
Thanks again for your help.

You are welcome.
Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: leroybt.rm | last post by:
Can someone tell me how to run a script from a interactive shell I type the following: >>>python filename >>>python filename.py >>>run filename >>>run filename.py >>>/run filename >>>/run...
4
by: Ed | last post by:
Hello, I took a course in asp about 2 years ago and I was practicing with IIS 5.0. Then I put it down for a while. Now trying to get back to it. I can't run asp files from subdirectories of...
2
by: Jenna Olson | last post by:
Hi all- I've never seen this particular issue addressed, but was wondering if there's anything to support one way or another. Say I have a class: class ManipulateData { public:...
7
by: erniedude | last post by:
Hi, I'm a newbie and I was wondering if anyone knew a (Python) script to run 4 batch files, one after the other (assuming the directories are known). It would be better if all 4 batch files...
3
by: Dan Hicks | last post by:
Hi, I wrote this test code as part of a module I created for the Northwind database. However, I was only using this as a test platform. My goal was to write a program that would take records...
6
by: billr | last post by:
I have developed a small API for taking care of a lot of boiler plate stuff in a multi formed windows application, for example setting up a messaging thread framework. New Forms, in the...
19
by: n0sPaM | last post by:
Is it possible to schedule an .ASPX page to run automatically, say every hour? N.B.
13
by: Bob Day | last post by:
Using vs2003, vb.net I start a thread, giving it a name before start. Code snippet: 'give each thread a unique name (for later identification) Trunk_Thread.Name = "Trunk_0_Thread" ' allow...
26
by: Chief | last post by:
Hello i would like to know which syntax do i have to use in order to make a program run other *.exe program and also how to put inputs in it for example i want to to make a program that run...
8
by: Sean DiZazzo | last post by:
Is there something special you have to do to get a wxPython app to run remotely under xwindows? My Tkinter apps always automatically work that way, so I was surprised to even be confronted with...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.