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
|
|||
|
|||
Report code
Hi
I have the below code that runs off a command button on my form. It prints two copies of the report which is fine but it is actually applying itself to each record so when i select the command it prints this report for every record. Is there any way to specify that the report only prints based on the current/selected record that is in view? any help appreciated. Private Sub Print10b_Click() On Error GoTo Err_Print10b_Click Dim stDocName As String stDocName = "10bConfirmation" DoCmd.OpenReport stDocName, acNormal, , strWhere DoCmd.OpenReport stDocName, acNormal, , strWhere Exit_Print10b_Click: Exit Sub Err_Print10b_Click: MsgBox Err.Description Resume Exit_Print10b_Click End Sub |
#2
|
|||
|
|||
You would add code for a "where" clause
Private Sub Print10b_Click() On Error GoTo Err_Print10b_Click Dim strWhere as String Dim stDocName As String strWhere = "[NumericID]=" & Me.txtNumericID stDocName = "10bConfirmation" DoCmd.OpenReport stDocName, acNormal, , strWhere DoCmd.OpenReport stDocName, acNormal, , strWhere Exit_Print10b_Click: Exit Sub Err_Print10b_Click: MsgBox Err.Description Resume Exit_Print10b_Click End Sub -- Duane Hookom MS Access MVP "A Moloney" wrote in message ... Hi I have the below code that runs off a command button on my form. It prints two copies of the report which is fine but it is actually applying itself to each record so when i select the command it prints this report for every record. Is there any way to specify that the report only prints based on the current/selected record that is in view? any help appreciated. Private Sub Print10b_Click() On Error GoTo Err_Print10b_Click Dim stDocName As String stDocName = "10bConfirmation" DoCmd.OpenReport stDocName, acNormal, , strWhere DoCmd.OpenReport stDocName, acNormal, , strWhere Exit_Print10b_Click: Exit Sub Err_Print10b_Click: MsgBox Err.Description Resume Exit_Print10b_Click End Sub |
#3
|
|||
|
|||
A Moloney wrote:
I have the below code that runs off a command button on my form. It prints two copies of the report which is fine but it is actually applying itself to each record so when i select the command it prints this report for every record. Is there any way to specify that the report only prints based on the current/selected record that is in view? any help appreciated. Private Sub Print10b_Click() On Error GoTo Err_Print10b_Click Dim stDocName As String stDocName = "10bConfirmation" DoCmd.OpenReport stDocName, acNormal, , strWhere DoCmd.OpenReport stDocName, acNormal, , strWhere Exit_Print10b_Click: Exit Sub Err_Print10b_Click: MsgBox Err.Description Resume Exit_Print10b_Click End Sub You never specified a filter expression for the WhereCondition argument. Add a line of code something like: strWhere = "keyfield = " & keytextbox -- Marsh MVP [MS Access] |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Specify Filter criteria before running report | Nikos Yannacopoulos | Setting Up & Running Reports | 3 | June 25th, 2004 09:36 PM |
Open a report based on which query I select | Sierras | Setting Up & Running Reports | 8 | June 24th, 2004 05:43 PM |
need help make a report | [email protected] | General Discussion | 2 | June 16th, 2004 08:31 PM |
Bug in Access 2002 Reports | notbitmonk | Setting Up & Running Reports | 10 | May 22nd, 2004 05:47 PM |
Query opens over report | Al Camp | New Users | 6 | May 17th, 2004 04:35 AM |