473,245 Members | 1,628 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,245 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 2223
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.