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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|
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 |