Can't find field. Error 2465 (1 Viewer)

kirkm

Registered User.
Local time
Tomorrow, 06:01
Joined
Oct 30, 2008
Messages
1,257
From a button click event I'm trying to debug print the value of a field
Code:
debug.print Form_frmList!FileSpec
If I put a Stop in the code and paste that line into the immediate window there is not error and the correct value is shown.
Why does it go to error in the click event ?
The field does exist in the query the Form is based on, but there is no control for that field on the Form. But this is true for some other fields in the query yet I can debug.print them.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:01
Joined
Oct 29, 2018
Messages
21,358
Hi. Is the button on frmList or a different form?
 

kirkm

Registered User.
Local time
Tomorrow, 06:01
Joined
Oct 30, 2008
Messages
1,257
The button is on the Main Form and frmlist is there also but as a datasheet. A subForm? (this confuses me a bit)
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:01
Joined
Oct 29, 2018
Messages
21,358
The button is on the Main Form and frmlist is there also but as a datasheet. A subForm? (this confuses me a bit)

What is the name of the main form?
 

isladogs

MVP / VIP
Local time
Today, 17:01
Joined
Jan 14, 2017
Messages
18,186
Debug.Print Me.filespec if on the same form

Or

Debug.Print Forms!frmList.FileSpec if on another form

Or

Debug.Print Me.frmList.Form.FileSpec if on a subform
 
Last edited:

kirkm

Registered User.
Local time
Tomorrow, 06:01
Joined
Oct 30, 2008
Messages
1,257
Many thanks for the replies. I'm sorry this is the sort of thing that drives me crazy. I've spent over 2 hours on this and suddenly it starts working. I've done nothing to fix it.


Trying Colins examples here doesn't seem to work. Is this a clue of some kind?

Debug.Print Forms!frmList.FileSpec
error 2450 Microsoft Access cannot find the referenced form 'frmList'.
Debug.Print Me.frmList.Form.FileSpec
Method or data member not found (with .frmList highlighted)


Debug.Print Form_frmList!FileSpec
This is now working every time.
 

Users who are viewing this thread

Top Bottom