Access 2003, Run-Time Error 2491, Forms/Query/Filter

I am receiving the Run-Time Error 2491 while trying to execute an "On Click" event.

I have a form Called [QreValue] and with in that form I have a sub form called [fQreValueSubform]. I have an "On Click" event where I select the "record selector on the subform. This executes a Query/Filter that joins the QREVALE Table to the subform.

It works very well. However, this is not the final product.
The QREVALUE form is then moved into another form Called fMain. fMain is a tabbed form that has several different forms embeded.

The QREVALUE form is placed on a tab/sheet called fQreValueMainSubform.

After doing this my "On Click" does not function. When I perform the "On Click" in the record selector I get the Run-Time Error 2491.

I have attached the db below. Please open two form and see what happens.
Open:  fQreValue » Select "All NAMC" » "Select a record" and the filter works fine.
Open: fMain » QRE VALUE tab » Select "All NAMC" » "Select a record"  and the error occurs.

I think I need to have all the forms bound together correctly. But am not sure how to do it.
The filter query has the following SQL Code. This
SELECT QREVALUE.TagNumber
FROM QREVALUE
WHERE (((QREVALUE.TagNumber)=[forms]![fQreValue]![qQreValueOpenSubform]![TagNumber]));

Open in new window

Quality--2-.zip
ggodwinAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
ok - do this:

Open: fMain » QRE VALUE tab » Select "All NAMC" » "Select a record"   (don't click)

Then ... go to the database window ... and try to open  QFQreValueOpen

You will get a parameter prompt - which is the problem, because the filter cannot be applied with this error.

You need to fix this.

mx
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
When fMain is open - the query is referencing

[forms]![fQreValue]![qQreValueOpenSubform]![TagNumber]
             ^^^^^^^^^^

Create a 2nd filter query ... and reference fMain

mx
ggodwinAuthor Commented:
Database MX:
Yes that is the case. In fact if you just navigate to the QFQreValueOpen. It iwll give that parameter.
However, when you go to the QREVALUE form and select it as it should be it works like it should.

So why does it not work with the other form?
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

Rey Obrero (Capricorn1)Commented:
test this

the  QFQreValueOpen must be

SELECT QREVALUE.TagNumber
FROM QREVALUE
WHERE (((QREVALUE.TagNumber)=[Forms]![fQreValueOpen]![TagNumber]));


and the click event codes

Private Sub Form_Click()
'DoCmd.ApplyFilter "QFQreValueOpen"
Me.Parent.Filter = "[TagNumber]='" & Me.TagNumber & "'"
Me.Parent.FilterOn = True

End Sub

QualityManagement.zip

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
"So why does it not work with the other form?"

Here:  http:#a23544745  different form name is open.  You are referencing the other form in this query.

mx
ggodwinAuthor Commented:
RE:
"DatabaseMX:When fMain is open - the query is referencing

[forms]![fQreValue]![qQreValueOpenSubform]![TagNumber]
Create a 2nd filter query ... and reference fMain"

I must have done this wrong. When I reference fMain like below.
[forms]![fMain]![qQreValueOpenSubform]![TagNumber]
For some reason the SQL code reverts back to the previous code??

Is my syntax above correct?
ggodwinAuthor Commented:
Capricorn,
With that sub function I get the exact same error.
Rey Obrero (Capricorn1)Commented:
use the db that i uploaded.

ggodwinAuthor Commented:
So, you had my command to execute the Query commented out. I did not have mine commented out is why it did not work. Based on you code, can I get rid of all the "QF Query/filters" that I have?

But yes this is exactly what I need.
Rey Obrero (Capricorn1)Commented:
yes..
ggodwinAuthor Commented:
This solution did more than solve my issue. It also solved another issue known as "data base Clutter".

Thanks for the help this is fantastic.
ggodwinAuthor Commented:
Capricorn,
For some reason, I am having a hard time getting this to work on the other forms.
fQreValueOpen
is the same as
fQreValueNUMMI,TMMKVEH,TMMI,TMMKPWT etc....(all of them that are fQreValue*****)
When I put that code behind each form. The forms are empty when I go back to view/test it?

Is there more to it than just replace the codes?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.