472,805 Members | 923 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 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 9790
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.