473,396 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Can I Pass this Filter: ([Lookup_Field1].[Field1]="TYPE1"))) From Form to Report?

I have a form which lists studies. People can filter the form based
on
details about the study, such as the study type. Currently users
filter via
the right click method.

I would like to be able to have a report that shows just the filtered
records.

The code that I tried which didn't work:

Private Sub print_detail_Click()
On Error GoTo Err_print_detail_Click
DoCmd.Minimize
Dim stDocName As String
stDocName = "RptStudyInformationDetail"
'Debug.Print Me.Filter
'Debug.Print Me.RecordSource
DoCmd.openreport stDocName, acViewPreview, , Me.Filter, ,
Me.RecordSource
Reports!RptStudyInformationDetail.FilterOn = True
Exit_print_detail_Click:
Exit Sub

Err_print_detail_Click:
MsgBox Err.Description
Resume Exit_print_detail_Click

End Sub

The Debug Window read the following for Me.Recordsource:
SELECT TblMainStudyInformation.* FROM TblMainStudyInformation INNER
JOIN
[TblChoicesNames] ON TblMainStudyInformation.[Study Director] =
[TblChoicesNames].NameCode WHERE ((([last name] & ',' & [first
initial] &
[middle initial])='Smith,JM'));

And the following for Me.Filter:
((([Lookup_Test System].[Test System]="SYSTEMTYPE1"))) AND
((Lookup_Sponsor.Initials="RWW"))

Anybody have any idea how to make this work?

Thanks,
Beth

Mar 15 '07 #1
3 2240
Access 2002 and later produce this kind of Filter string when you filter on
a combo where the visible column is not the bound column.

You cannot pass that to the report directly, since the report doesn't
understand the "Lookup_Field" part. But there is a fudge. Create a query
that includes the lookup table, and *alias* it so that the name matches what
it's called in the Filter string. If the name matches, Access will be able
to make sense of it in the report.

To alias the table:
1. Open the query in design view.

2. Right-click the lookup table in the upper pane of query design, and
choose Properties.

3. Set the Alias property to:
Lookup_Field1
i.e. use exactly the same name as you see in your Filter string.

The OpenReport will then work.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<em*********@snet.netwrote in message
news:11**********************@b75g2000hsg.googlegr oups.com...
>I have a form which lists studies. People can filter the form based
on
details about the study, such as the study type. Currently users
filter via
the right click method.

I would like to be able to have a report that shows just the filtered
records.

The code that I tried which didn't work:

Private Sub print_detail_Click()
On Error GoTo Err_print_detail_Click
DoCmd.Minimize
Dim stDocName As String
stDocName = "RptStudyInformationDetail"
'Debug.Print Me.Filter
'Debug.Print Me.RecordSource
DoCmd.openreport stDocName, acViewPreview, , Me.Filter, ,
Me.RecordSource
Reports!RptStudyInformationDetail.FilterOn = True
Exit_print_detail_Click:
Exit Sub

Err_print_detail_Click:
MsgBox Err.Description
Resume Exit_print_detail_Click

End Sub

The Debug Window read the following for Me.Recordsource:
SELECT TblMainStudyInformation.* FROM TblMainStudyInformation INNER
JOIN
[TblChoicesNames] ON TblMainStudyInformation.[Study Director] =
[TblChoicesNames].NameCode WHERE ((([last name] & ',' & [first
initial] &
[middle initial])='Smith,JM'));

And the following for Me.Filter:
((([Lookup_Test System].[Test System]="SYSTEMTYPE1"))) AND
((Lookup_Sponsor.Initials="RWW"))

Anybody have any idea how to make this work?

Thanks,
Beth
Mar 15 '07 #2
I must be missing something.

I have tried the suggestion several ways, and every time I get the
error message:

"Joined Table 'RptStudyInformationDetail' not listed in FROM clause"

Of course RptStudyInformationDetail isn't a table but instead the name
of my report. Is it not working because I am setting the recordsource
of the report on the open event?

I really appreciate the help!

Beth

Mar 15 '07 #3
Don't use the report name in the SQL statement.

To use an example from the Northwind sample database that installs with
Access, open the Orders form, select the Customer combo, and click the
Filter By Selection button on the toolbar. The Filter of the form will now
contain something like this:
([Lookup_CustomerID].[CompanyName]="Alfreds Futterkistez")

Now create a query, switch to SQL View, and paste this in:
SELECT Orders.*, Lookup_CustomerID.CompanyName
FROM Customers AS Lookup_CustomerID
INNER JOIN Orders ON Lookup_CustomerID.CustomerID = Orders.CustomerID
WHERE (Lookup_CustomerID.CompanyName="Alfreds Futterkistez");

Do you see that the Customers table has been aliased so that it matches the
name used in the Filter? If you now created a report based on this query,
the form's filter would work for the report also.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<em*********@snet.netwrote in message
news:11**********************@e65g2000hsc.googlegr oups.com...
>I must be missing something.

I have tried the suggestion several ways, and every time I get the
error message:

"Joined Table 'RptStudyInformationDetail' not listed in FROM clause"

Of course RptStudyInformationDetail isn't a table but instead the name
of my report. Is it not working because I am setting the recordsource
of the report on the open event?

I really appreciate the help!

Beth
Mar 15 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Richard | last post by:
Hi, I have a form based on a table. When I filter the form I want to run a report based on the same table with the same filter as the form. No problem until I want to filter a combo box where...
1
by: Scott Sabo | last post by:
I have a form & report based on a query which shows details about employees performance reviews (hire date, review date, review submital date, etc). We do 90 day probation reviews as well and I...
0
by: ghadley_00 | last post by:
MS Access Create form / report with multiple pages using different background images Hi, Would like to have users fill out a multipage form, and then click a print button, which pulls up the...
2
by: Roger | last post by:
Anyone know how to pass a parameter to a query via a report in Access 2003?
1
by: LabWINC | last post by:
Hi all, i would like to design a high pass filter with scipy.signal module. This is the code i'm using to: import scipy.signal as signal import scipy #first of all i design the lowpass fir...
7
by: Boki | last post by:
Hi All, I can't pass data to another form: in form2: private void button1_Click(object sender, EventArgs e) { Form1 form_copy = new Form1();
6
by: kpfunf | last post by:
I have one form called Accounts, on which there is a command button called EnterNewTransactionButton. This opens another form called Transactions. I want to add some code that will take the value of...
1
Kosal
by: Kosal | last post by:
Dear Sir/Madam I would like you to help give me the an example pass multi parameter to crystal report. thanks Best Regard Kosal
2
by: sap01 | last post by:
Hi All, I want to display the data from a table by applying filter in the form. I want three combo box filter in the form. If I select all the three then it should display the data in the form from...
2
by: Ian Anderson | last post by:
Hello there, SO i have the followign VB code in my continuous form... 'Purpose: This module illustrates how to create a search form, _ where the user can enter as many or few...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.