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  

Report code



 
 
Thread Tools Display Modes
  #1  
Old September 9th, 2004, 02:28 PM
A Moloney
external usenet poster
 
Posts: n/a
Default 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  
Old September 9th, 2004, 02:39 PM
Duane Hookom
external usenet poster
 
Posts: n/a
Default

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  
Old September 9th, 2004, 02:49 PM
Marshall Barton
external usenet poster
 
Posts: n/a
Default

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

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


All times are GMT +1. The time now is 01:16 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.