Database Can't find the field '|' referred to in your expression

G

Guest

I get the following error when open this form or try to save data in this
form -
"Database Can't find the field '|' referred to in your expression"

while saving if I choose to debug, I get to the following code -


******************
Private sub subform_exit (cancel as integer)

If isnull([JOB_NO]) or [JOB_NO] = "" then
msgbox ("Please enter the job no.")
Cancel = True
errno = 0
JOB_NO.SetFocus
Exit Sub
ivalue = (Msgbox ("do you want to save job no changes? ", 547, "update"))
If ivalue = 2 then
cancel ..

elseif
...

DoCmd.Save
Else
Form.undo
End if
End sub

****************

What am I doing wrong?

Thank you,
-Me
 
A

Allen Browne

1. Move the code into BeforeUpdate event of the form instead of the Exit
event of the subform control. Form_BeforeUpdate always fires, regardless of
how the update occurred. (The subform's Exit event probably won't even fire
until after the record is saved.)

2. Test that the code compiles, by choosing Compile on the Debug menu (in
the code window.)

If the code still generates the error, indicate which line is highlighted
when you choose Debug.

If the error occurs on the first keystroke you enter in the subform, is this
subform based on a query that uses more than one table?
 
G

Guest

Hi Allen,

I changed to BeforeUpdate event and I stopped getting that error. I will
have to observer it for a while. 'cause in my another program, I keep getting
similar error upon form open event if the data contains double-quotes ("")
for example I have a contractno field on form, someone entered "1234" in
this field
instead of 1234. It saves the record just fine. However, when they open the
form subsequently it give the same error " database can't find the field |
...."

I corrected the data, but there were some other instances too where I was
getting similar error. I think I will have to keep on observing.

Thank you very much for your help!
-Me


Allen Browne said:
1. Move the code into BeforeUpdate event of the form instead of the Exit
event of the subform control. Form_BeforeUpdate always fires, regardless of
how the update occurred. (The subform's Exit event probably won't even fire
until after the record is saved.)

2. Test that the code compiles, by choosing Compile on the Debug menu (in
the code window.)

If the code still generates the error, indicate which line is highlighted
when you choose Debug.

If the error occurs on the first keystroke you enter in the subform, is this
subform based on a query that uses more than one table?

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

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

Me said:
I get the following error when open this form or try to save data in this
form -
"Database Can't find the field '|' referred to in your expression"

while saving if I choose to debug, I get to the following code -


******************
Private sub subform_exit (cancel as integer)

If isnull([JOB_NO]) or [JOB_NO] = "" then
msgbox ("Please enter the job no.")
Cancel = True
errno = 0
JOB_NO.SetFocus
Exit Sub
ivalue = (Msgbox ("do you want to save job no changes? ", 547, "update"))
If ivalue = 2 then
cancel ..

elseif
..

DoCmd.Save
Else
Form.undo
End if
End sub

****************
 

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