• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2007
  • Last Modified:

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
0
ggodwin
Asked:
ggodwin
  • 6
  • 3
  • 3
1 Solution
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
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
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
When fMain is open - the query is referencing

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

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

mx
0
 
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?
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
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
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
"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
0
 
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?
0
 
ggodwinAuthor Commented:
Capricorn,
With that sub function I get the exact same error.
0
 
Rey Obrero (Capricorn1)Commented:
use the db that i uploaded.

0
 
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.
0
 
Rey Obrero (Capricorn1)Commented:
yes..
0
 
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.
0
 
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?
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 6
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now