PC Review


Reply
 
 
A Moloney
Guest
Posts: n/a
 
      9th Sep 2004
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
 
Reply With Quote
 
 
 
 
Duane Hookom
Guest
Posts: n/a
 
      9th Sep 2004
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" <(E-Mail Removed)> wrote in message
news:8d0201c49670$f3ccdf10$(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
 
Marshall Barton
Guest
Posts: n/a
 
      9th Sep 2004
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]
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Report with Sub-Report with NO-DATA on Sub-Report =?Utf-8?B?Um9iZXJ0IE51c3ogQCBEUFM=?= Microsoft Access Reports 11 16th Feb 2006 06:20 PM
Printing report b after report a prints using report a's variables =?Utf-8?B?QmxhemU=?= Microsoft Access Reports 0 8th Feb 2006 10:46 PM
[New] Zipoid - ZIP Code, City Name and Area Code Lookup - Zip Code to Zip Code Distance Calculation Mel Freeware 0 22nd Jul 2005 04:13 PM
Report / Sub report data source lost when adding a new sub report =?Utf-8?B?Sm9lIE1jQw==?= Microsoft Access Reports 5 4th Apr 2005 07:27 PM
Report button linked to exact report record- Open report method? =?Utf-8?B?UmljaA==?= Microsoft Access Forms 1 27th May 2004 06:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:45 AM.