MS Access 2000 run-time error '2465' "can't find the field 'Forms' referred"

B

bmagnuso

One form gets a user-selected item from a list box:

-----
Private Sub click_get_po_item_Click()
Dim sGen As String
Dim stLinkCriteria As String
Dim stDocName As String
Dim iRet As Integer

If IsNull(Me![po_num_sel]) = True Then
sGen = "Please highlight a PO from the list!"
iRet = MsgBox(sGen, 32, "No PO Selected")
GoTo ExitSubLoc
End If

stLinkCriteria = "[po_num]=" & Me![po_num_sel] 'set up to find the
record desired
stDocName = "mf3"

DoCmd.OpenForm stDocName, acNormal, , , acFormEdit, acWindowNormal,
stLinkCriteria

ExitSubLoc:
End Sub
-----

The called form checks for open arguments to do a find-first to that record:

-----
Private Sub Form_Open(Cancel As Integer)
If Not IsNull(Forms![mf3].OpenArgs) Then
Dim strQueryOnID As String
Dim rs As DAO.Recordset

strQueryOnID = Forms![mf3].OpenArgs
Set rs = Forms![mf3].RecordsetClone
rs.FindFirst strQueryOnID

If Not rs.NoMatch Then
Forms![mf3].Bookmark = rs.Bookmark
End If
End If
End Sub
------

At the "Forms![mf3].Bookmark line, the 2465 run-time error occurs with the
USELESS
ERROR MESSAGE "can't find the field 'Forms' referred".

I can't myself find any field "Forms" anywhere. HELP!
Thanks!
 
A

Allen Browne

Okay, I have seen Access get confused like that too, but I have not
pinpointed the exact cause, so these suggestions will be a bit generic.

1. Make sure you have SP3 for Office 2000, and SP8 for JET 4 on your dev
machine. Make sure the client has the runtime patches and JET 8 SP8 on their
machine. Source:
http://support.microsoft.com/gp/sp

2. Uncheck the boxes under:
Tools | Options | General | Name AutoCorrect
Then compact the database to get rid of this junk:
Tools | Database Utilities | Compact
Explanation of why:
http://allenbrowne.com/bug-03.html

3. Close Access. Make a backup copy of the file. Decompile the database by
entering something like this at the command prompt while Access is not
running. It is all one line, and include the quotes:
"c:\Program Files\Microsoft office\office\msaccess.exe" /decompile
"c:\MyPath\MyDatabase.mdb"

4. Open Access, and compact again.

5. If the problem still persists at this point, copy everything from the
form's module out to Notepad, and set the form's HasModule property to No.
Save and close the form. Compact the database again. Then open the form's
module, and paste the code back in.

6. I take it that the code goes in the called form, so could you use Me
instead of Forms![mf3]? If not, try explicitly declaring a Form variable,
i.e.:
Dim frm As Form
Set frm = Forms!mf3
Although Access will let you use the form's Open event, it would make more
sense to me to use the Load event to move record.

Private Sub Form_Load()
Dim strQueryOnID As String
Dim rs As DAO.Recordset

If Nz(Me.OpenArgs, vbNullString) <> vbNullString Then
strQueryOnID = Me.OpenArgs
Set rs = Me.RecordsetClone
rs.FindFirst strQueryOnID
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
End If
End If
End Sub

7. Presumably you do have error handling in these events--essential for
runtime.

8. Make sure you have minimal references chosen.
More info on references:
http://allenbrowne.com/ser-38.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

bmagnuso said:
One form gets a user-selected item from a list box:

-----
Private Sub click_get_po_item_Click()
Dim sGen As String
Dim stLinkCriteria As String
Dim stDocName As String
Dim iRet As Integer

If IsNull(Me![po_num_sel]) = True Then
sGen = "Please highlight a PO from the list!"
iRet = MsgBox(sGen, 32, "No PO Selected")
GoTo ExitSubLoc
End If

stLinkCriteria = "[po_num]=" & Me![po_num_sel] 'set up to find the
record desired
stDocName = "mf3"

DoCmd.OpenForm stDocName, acNormal, , , acFormEdit, acWindowNormal,
stLinkCriteria

ExitSubLoc:
End Sub
-----

The called form checks for open arguments to do a find-first to that
record:

-----
Private Sub Form_Open(Cancel As Integer)
If Not IsNull(Forms![mf3].OpenArgs) Then
Dim strQueryOnID As String
Dim rs As DAO.Recordset

strQueryOnID = Forms![mf3].OpenArgs
Set rs = Forms![mf3].RecordsetClone
rs.FindFirst strQueryOnID

If Not rs.NoMatch Then
Forms![mf3].Bookmark = rs.Bookmark
End If
End If
End Sub
------

At the "Forms![mf3].Bookmark line, the 2465 run-time error occurs with
the
USELESS
ERROR MESSAGE "can't find the field 'Forms' referred".

I can't myself find any field "Forms" anywhere. HELP!
Thanks!
 
B

bmagnuso via AccessMonster.com

Allen: Thanks for all the suggestions. Comments at --->

Allen said:
Okay, I have seen Access get confused like that too, but I have not
pinpointed the exact cause, so these suggestions will be a bit generic.

1. Make sure you have SP3 for Office 2000, and SP8 for JET 4 on your dev
machine. Make sure the client has the runtime patches and JET 8 SP8 on their
machine. Source:
http://support.microsoft.com/gp/sp

---> For what it's worth, at this client site, the best I could do was to
install Access 2000 into an Office 2002 installation which did NOT already
have Access installed. This is temporary and when my project gets approval,
likely IT will install a legit copy of Access 2002. I did however install
the Jet 4 SP8 w/o prob.
2. Uncheck the boxes under:
Tools | Options | General | Name AutoCorrect
Then compact the database to get rid of this junk:
Tools | Database Utilities | Compact
Explanation of why:
http://allenbrowne.com/bug-03.html

---> Done.
3. Close Access. Make a backup copy of the file. Decompile the database by
entering something like this at the command prompt while Access is not
running. It is all one line, and include the quotes:
"c:\Program Files\Microsoft office\office\msaccess.exe" /decompile
"c:\MyPath\MyDatabase.mdb"

---> I think it ran.
4. Open Access, and compact again.

5. If the problem still persists at this point, copy everything from the
form's module out to Notepad, and set the form's HasModule property to No.
Save and close the form. Compact the database again. Then open the form's
module, and paste the code back in.

---> Done. __Problem still exists__. :(
6. I take it that the code goes in the called form, so could you use Me
instead of Forms![mf3]? If not, try explicitly declaring a Form variable,
i.e.:
Dim frm As Form
Set frm = Forms!mf3
Although Access will let you use the form's Open event, it would make more
sense to me to use the Load event to move record.

Private Sub Form_Load()
Dim strQueryOnID As String
Dim rs As DAO.Recordset

If Nz(Me.OpenArgs, vbNullString) <> vbNullString Then
strQueryOnID = Me.OpenArgs
Set rs = Me.RecordsetClone
rs.FindFirst strQueryOnID
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
End If
End If
End Sub

---> Originally the code used the Me! variation you mention. Would you be
so kind as to elaborate
on the use of the "Load event" to "move the record"?
7. Presumably you do have error handling in these events--essential for
runtime.

---> The only error handling I have added is when record navigation reaches
the
first and last records and the user tries to continue in a direction where no
more
records exist.

---> Would extra error handling help isolate the error or ?
8. Make sure you have minimal references chosen.
More info on references:
http://allenbrowne.com/ser-38.html

---> Done, removed a few references not recommended.

This absurd bug remains, and I have looked extensively on the 'net for help,
leading me
here to sign up.

Would you happen to know of an SQL or non-DAO way to set a record as current,
based
on a user selection in another form?

Much appreciated,
Bob
One form gets a user-selected item from a list box:
[quoted text clipped - 49 lines]
I can't myself find any field "Forms" anywhere. HELP!
Thanks!
 
A

Allen Browne

#6: The Open verses Load event is *really* minor.
Open fires first. You cancel it if you don't want to proceed.
The Load event fires when it loads the records.
It just makes more sense to me to try to find the record once it's loaded
rather than before, even the Access is forgiving and it will work in
Form_Open anyway. I have observed that if you do stuff in Form_Open that
forces it to load the records, the other form events (such as Current,
Activate) can occur in an order that is different to the published sequence
of events for forms.

#7: From the code window, choose Options on the Tools menu.
On the General tab, make sure Error Trapping is set to:
Break on Unhandled Errors
Otherwise you may not get notified of the errors.

Other
====
Now that you have Me instead of Forms!mp3, there is no "Forms" in the code.
Can you indicate which line fails with the error message:
"can't find the field 'Forms' referred"

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

bmagnuso via AccessMonster.com said:
Allen: Thanks for all the suggestions. Comments at --->
6. I take it that the code goes in the called form, so could you use Me
instead of Forms![mf3]? If not, try explicitly declaring a Form variable,
i.e.:
Dim frm As Form
Set frm = Forms!mf3
Although Access will let you use the form's Open event, it would make more
sense to me to use the Load event to move record.

Private Sub Form_Load()
Dim strQueryOnID As String
Dim rs As DAO.Recordset

If Nz(Me.OpenArgs, vbNullString) <> vbNullString Then
strQueryOnID = Me.OpenArgs
Set rs = Me.RecordsetClone
rs.FindFirst strQueryOnID
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
End If
End If
End Sub

---> Originally the code used the Me! variation you mention. Would you
be
so kind as to elaborate
on the use of the "Load event" to "move the record"?
7. Presumably you do have error handling in these events--essential for
runtime.

---> The only error handling I have added is when record navigation
reaches
the
first and last records and the user tries to continue in a direction where
no
more
records exist.

---> Would extra error handling help isolate the error or ?
8. Make sure you have minimal references chosen.
More info on references:
http://allenbrowne.com/ser-38.html

---> Done, removed a few references not recommended.

This absurd bug remains, and I have looked extensively on the 'net for
help,
leading me
here to sign up.

Would you happen to know of an SQL or non-DAO way to set a record as
current,
based
on a user selection in another form?

Much appreciated,
Bob
One form gets a user-selected item from a list box:
[quoted text clipped - 49 lines]
I can't myself find any field "Forms" anywhere. HELP!
Thanks!
 
B

bmagnuso via AccessMonster.com

Allen said:
#6: The Open verses Load event is *really* minor.
Open fires first. You cancel it if you don't want to proceed.
The Load event fires when it loads the records.
It just makes more sense to me to try to find the record once it's loaded
rather than before, even the Access is forgiving and it will work in
Form_Open anyway. I have observed that if you do stuff in Form_Open that
forces it to load the records, the other form events (such as Current,
Activate) can occur in an order that is different to the published sequence
of events for forms.

---> Ok, I've shifted the code to the "Load" event. Error still occurs (see
below for location).
I've been working on other functionality for the DB in the mean time.
#7: From the code window, choose Options on the Tools menu.
On the General tab, make sure Error Trapping is set to:
Break on Unhandled Errors
Otherwise you may not get notified of the errors.

---> That helps with a custom popup when the user tries to scan beyond first
/ last record.
Other
====
Now that you have Me instead of Forms!mp3, there is no "Forms" in the code.
Can you indicate which line fails with the error message:
"can't find the field 'Forms' referred"

Debugging into the code, the <<<--------- line is highlighted:

Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
Dim strQueryOnID As String
Dim rs As DAO.Recordset

strQueryOnID = Me.OpenArgs
Set rs = Me.RecordsetClone
rs.FindFirst strQueryOnID

If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark <<<-----------
End If
End If
End Sub

Much appreciated,
Bob
 
A

Allen Browne

This has to be either a naming clash (you have something else named Forms),
or a corruption of the database, because the word Forms does not appear on
that line.

If you are certain there is nothing else on this form named Forms, it might
be easiest to create a new form. It might be easiest to copy the code out to
notepad and save it as a text file, delete the form, compact the database,
create the form again from scratch, and paste the text into its module.
 
B

bmagnuso via AccessMonster.com

Hmmm.

I was poking around in perhaps an object browser or something, and found
scads and scads
of parameters about the form, the fields, etc. Problem is, I don't know how
to get back to where
I was in Access to see and search for any field named "Forms".

At one point I un-hid the system tables, looked around in there, found a lot
of gibberish in
the "MSysAccessObjects" table...

Isn't there some way to see the behind-the-scenes parameters / variables to
check if any contain
a suspicious "Forms" string? Previously, you suggested steps that seemed an
effort to "purge"
(with the compact step) this, but compact doesn't seem to do anything.

How about some shareware / freeware tools to examine Access from the outside -
anything like
that a possibility that you know of?

Thanks,
Bob

This has to be either a naming clash (you have something else named Forms),
or a corruption of the database, because the word Forms does not appear on
that line.

If you are certain there is nothing else on this form named Forms, it might
be easiest to create a new form. It might be easiest to copy the code out to
notepad and save it as a text file, delete the form, compact the database,
create the form again from scratch, and paste the text into its module.
#6: The Open verses Load event is *really* minor.
Open fires first. You cancel it if you don't want to proceed. [quoted text clipped - 50 lines]
I can't myself find any field "Forms" anywhere. HELP!
Thanks!
 
A

Allen Browne

If you are seeing lots of gibberish in MSysAccessObjects, I suggest you get
Access to recreate the database for you.

Follow the steps for the first symptom in:
Recovering from corruption
at:
http://allenbrowne.com/ser-47.html

There is a free utility to check your tables for bad field names etc here:
Database Issue Checker
at:
http://allenbrowne.com/AppIssueChecker.html

If you open your form in design view, the left-end of the toolbar has a
drop-down for selecting the controls by name. Controls are listed
alphabetically, so you could find any control named Forms there. In the
form's module (code window), you can use Edit in the Find menu to find any
occurance of Forms.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

bmagnuso via AccessMonster.com said:
Hmmm.

I was poking around in perhaps an object browser or something, and found
scads and scads
of parameters about the form, the fields, etc. Problem is, I don't know
how
to get back to where
I was in Access to see and search for any field named "Forms".

At one point I un-hid the system tables, looked around in there, found a
lot
of gibberish in
the "MSysAccessObjects" table...

Isn't there some way to see the behind-the-scenes parameters / variables
to
check if any contain
a suspicious "Forms" string? Previously, you suggested steps that seemed
an
effort to "purge"
(with the compact step) this, but compact doesn't seem to do anything.

How about some shareware / freeware tools to examine Access from the
outside -
anything like
that a possibility that you know of?

Thanks,
Bob

This has to be either a naming clash (you have something else named
Forms),
or a corruption of the database, because the word Forms does not appear on
that line.

If you are certain there is nothing else on this form named Forms, it
might
be easiest to create a new form. It might be easiest to copy the code out
to
notepad and save it as a text file, delete the form, compact the database,
create the form again from scratch, and paste the text into its module.
#6: The Open verses Load event is *really* minor.
Open fires first. You cancel it if you don't want to proceed.
[quoted text clipped - 50 lines]
I can't myself find any field "Forms" anywhere. HELP!
Thanks!
 
B

bmagnuso via AccessMonster.com

If you are seeing lots of gibberish in MSysAccessObjects, I suggest you get
Access to recreate the database for you.

I should have qualified this. While there are recognizable strings in MSAO
rows,
most have an "wingding" graphic box in place of what I guess would be regular
characters
in each row. I might copy the DB and just try a mass edit to see if anything
breaks.
Follow steps for first symptom in: Recovering from corruption at: http://allenbrowne.com/ser-47.html

I did, and when I imported from the original DB to a test DB, the problem
came along. I went
incrementally, when I imported the forms, macros and modules, it broke the
same way.
There is a free utility to check your tables for bad field names etc here: Database Issue Checker
at: http://allenbrowne.com/AppIssueChecker.html

It found no probs.
If you open your form in design view, the left-end of the toolbar has a
drop-down for selecting the controls by name. Controls are listed
alphabetically, so you could find any control named Forms there. In the
form's module (code window), you can use Edit in the Find menu to find any
occurance of Forms.

I'm using Access 2000, and I can't find a drop-down for selecting controls as
you mention.

Back to the line of code that blows up (marked by <<<<):

Me.Bookmark = rs.Bookmark
If Not IsNull(Me.OpenArgs) Then
Dim strQueryOnID As String
Dim rs As DAO.Recordset

strQueryOnID = Me.OpenArgs
Set rs = Me.RecordsetClone
rs.FindFirst strQueryOnID

If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark <<<<
End If
End If

Comment: I'm a 'C' programmer, not an Access VB or Office VB programmer.
This line that
stops program execution, ...if this was in 'C' we'd be dealing with two local
structures (the dot
seperates the structure name from structure member), and whatever value is in
struct rs
variable Bookmark is assigned to struct Me variable Bookmark. No other
variables are
involved in the _assignment_. But, apparently, at this point in program
execution there's
something more than _assignment_ going on, manifest by the error message
talking not
about "Bookmark" variables, but some missing field:

Microsoft Access can't find the field 'Forms' referred to in your expression

Humor me in my 'C' vernacular. Ok, in "debug" mode, in the "Locals" window,
I poked around
in the variables listed on the RIGHT side of "Me." as well as the right side
of "rs." The closest
I can come is Me.Form (not Forms) and rs.Fields. If I poke further, I get
deep into a rat's nest
of (apparently) more Access intrinsic settings and (Form) control details.

Now, if I pay attention only to Me.Bookmark and its subordinate structure
"members",
compared to rs.Bookmark and its subordinate structure members, I get (in the
"Locals" view):

(column header)
(Expression) (Value) (Type)

Me.Bookmark
Bookmark(0) 0 Byte
Bookmark(1) 2 Byte
Bookmark(2) 0 Byte
Bookmark(3) 0 Byte

and

rs.Bookmark
Bookmark(0) 11 Byte
Bookmark(1) 2 Byte
Bookmark(2) 0 Byte
Bookmark(3) 0 Byte

Still, nothing about missing field "Forms". I have no idea what rs.Bookmark
(0) = 11 means,
but it doesn't match Me.Bookmark(0), which is 0.

If I just KICK the damn computer really hard, will it straighten out??
:(

This feature of my design I'm trying to fix is _critical_ and really _not
replaceable_, I need to
give the user a list of items, whereupon one is selected and it calls up
another window where
details on that item are displayed. A redesign of the database would only
produce a less
efficient table layout and loss of already-designed functionality.

 
A

Allen Browne

Answers embedded.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

bmagnuso via AccessMonster.com said:
I should have qualified this. While there are recognizable strings in
MSAO
rows,
most have an "wingding" graphic box in place of what I guess would be
regular
characters
in each row. I might copy the DB and just try a mass edit to see if
anything
breaks.


I did, and when I imported from the original DB to a test DB, the problem
came along. I went
incrementally, when I imported the forms, macros and modules, it broke the
same way.


Some columns in MSysObjects contain long binary data, but Name should be
valid text, Type and Flags should be valid numbers. If these are broken, you
might need to determine which forms/reports/macros are corrupted (by
determining which names are not imported correctly). You can then build a
new database, import the valid objects, and rebuild the others (or import
those forms from an old backup.)

I'm using Access 2000, and I can't find a drop-down for selecting controls
as
you mention.


Screenshot of the object selector here:
http://allenbrowne.com/temp/ObjectSelector.png
using the Customers form from Northwind, in design view.

Back to the line of code that blows up (marked by <<<<):

Me.Bookmark = rs.Bookmark
If Not IsNull(Me.OpenArgs) Then
Dim strQueryOnID As String
Dim rs As DAO.Recordset

strQueryOnID = Me.OpenArgs
Set rs = Me.RecordsetClone
rs.FindFirst strQueryOnID

If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark <<<<
End If
End If

Comment: I'm a 'C' programmer, not an Access VB or Office VB programmer.
This line that
stops program execution, ...if this was in 'C' we'd be dealing with two
local
structures (the dot
seperates the structure name from structure member), and whatever value is
in
struct rs
variable Bookmark is assigned to struct Me variable Bookmark. No other
variables are
involved in the _assignment_. But, apparently, at this point in program
execution there's
something more than _assignment_ going on, manifest by the error message
talking not
about "Bookmark" variables, but some missing field:

rs is an object which has members (e.g. the Fields collection which is like
a structure) and properties (e.g. the Bookmark, which is like a pointer to
the current record.)

Me is an object (the instance of the form that contains this code), which
has members (e.g. the Fields collection and the Controls collection) and
methods (the event procedures) and properties (such as Visible.) The
Bookmark is like a pointer the the current record in the form.

So, when you assign the Bookmark of the RecordsetClone to the Bookmark of
the Form, you are setting the current record of the form to whichever was
the current record of Bookmark.
Microsoft Access can't find the field 'Forms' referred to in your
expression

Humor me in my 'C' vernacular. Ok, in "debug" mode, in the "Locals"
window,
I poked around
in the variables listed on the RIGHT side of "Me." as well as the right
side
of "rs." The closest
I can come is Me.Form (not Forms) and rs.Fields. If I poke further, I get
deep into a rat's nest
of (apparently) more Access intrinsic settings and (Form) control details.

Now, if I pay attention only to Me.Bookmark and its subordinate structure
"members",
compared to rs.Bookmark and its subordinate structure members, I get (in
the
"Locals" view):

(column header)
(Expression) (Value) (Type)

Me.Bookmark
Bookmark(0) 0 Byte
Bookmark(1) 2 Byte
Bookmark(2) 0 Byte
Bookmark(3) 0 Byte

and

rs.Bookmark
Bookmark(0) 11 Byte
Bookmark(1) 2 Byte
Bookmark(2) 0 Byte
Bookmark(3) 0 Byte


The Bookmark "pointer" actually consists of a Byte array.

Still, nothing about missing field "Forms". I have no idea what
rs.Bookmark
(0) = 11 means,
but it doesn't match Me.Bookmark(0), which is 0.

If I just KICK the damn computer really hard, will it straighten out??
:(


That will probably trigger the computer's "frustratometer".
It will then sulk until you "reboot" it. :)

This feature of my design I'm trying to fix is _critical_ and really _not
replaceable_, I need to
give the user a list of items, whereupon one is selected and it calls up
another window where
details on that item are displayed. A redesign of the database would only
produce a less
efficient table layout and loss of already-designed functionality.

The code you have makes perfect sense, so I can understand the frustration.
Presumably you have decompiled the project.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top