A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Create User Selectable Filter for a Report



 
 
Thread Tools Display Modes
  #1  
Old July 13th, 2004, 02:14 PM
Pete Sperling
external usenet poster
 
Posts: n/a
Default Create User Selectable Filter for a Report

I have a key field in a table that is used to link to other tables in a one to many relationship. Would like to be able to create a report that somehow allows the user to select which record in the key field of the table to base the report on. Is there a way to create a form that would open just prior to the report opening that would permit the user to select the specific record? I don't want to have to create a separate query and report for each of the records of the key field. Any help greatly appreciated. Pete
  #2  
Old July 13th, 2004, 02:37 PM
Allen Browne
external usenet poster
 
Posts: n/a
Default Create User Selectable Filter for a Report

Create the form, with a combo box for selecting the value, and a command
button to open the report.

This example assumes you have a combo named "cboField1", that has the value
to match against "Field1" in the report.

Private Sub cmdPreview_Click()
Dim strWhere As String

If Not IsNull(Me.cboField1) Then
strWhere = "[Field1] = " & Me.cboField1
End If

DoCmd.OpenReport "MyReport", acViewPreview, , strWhere
End Sub


Note: If Field1 is a Text field, you need to add extra quotes:
strWhere = "[Field1] = """ & Me.cboField1 & """"

--
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.

"Pete Sperling" wrote in message
...
I have a key field in a table that is used to link to other tables in a

one to many relationship. Would like to be able to create a report that
somehow allows the user to select which record in the key field of the table
to base the report on. Is there a way to create a form that would open just
prior to the report opening that would permit the user to select the
specific record? I don't want to have to create a separate query and report
for each of the records of the key field. Any help greatly appreciated.
Pete


  #3  
Old July 13th, 2004, 06:49 PM
Pete Sperling
external usenet poster
 
Posts: n/a
Default Create User Selectable Filter for a Report

Allen - Works great - Thanks for your assistance - Pete

"Allen Browne" wrote:

Create the form, with a combo box for selecting the value, and a command
button to open the report.

This example assumes you have a combo named "cboField1", that has the value
to match against "Field1" in the report.

Private Sub cmdPreview_Click()
Dim strWhere As String

If Not IsNull(Me.cboField1) Then
strWhere = "[Field1] = " & Me.cboField1
End If

DoCmd.OpenReport "MyReport", acViewPreview, , strWhere
End Sub


Note: If Field1 is a Text field, you need to add extra quotes:
strWhere = "[Field1] = """ & Me.cboField1 & """"

--
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.

"Pete Sperling" wrote in message
...
I have a key field in a table that is used to link to other tables in a

one to many relationship. Would like to be able to create a report that
somehow allows the user to select which record in the key field of the table
to base the report on. Is there a way to create a form that would open just
prior to the report opening that would permit the user to select the
specific record? I don't want to have to create a separate query and report
for each of the records of the key field. Any help greatly appreciated.
Pete



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
create and email a report Alex Paradi General Discussion 3 July 16th, 2004 05:30 PM
Save Report With CreateReport Coding Issue Jeff Conrad Setting Up & Running Reports 8 July 12th, 2004 08:39 AM
Creating a report from a form Kristin Setting Up & Running Reports 7 June 28th, 2004 09:21 PM
Label SRIT General Discussion 2 June 22nd, 2004 09:42 PM
What I would like to do is create a report from data stored with in a table (tbl_consultations) with the following criteria:- Barry McConomy General Discussion 1 June 7th, 2004 11:55 PM


All times are GMT +1. The time now is 12:17 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.