dbTalk Databases Forums  

Email function - restricting reports to current record

comp.database.ms-access comp.database.ms-access


Discuss Email function - restricting reports to current record in the comp.database.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
The Woo
 
Posts: n/a

Default Email function - restricting reports to current record - 05-13-2006 , 03:28 AM






Hello all!

I used the Command Button Wizard to put a button on my form which will
email a report to my colleague. Just one prob: it will email all the
records.

How do I restrict the report to just the currently-selected record?

Here's the code as it is now:



Private Sub Command1495_Click()
On Error GoTo Err_Command1495_Click

Dim stDocName As String

stDocName = "rptFinancials"
DoCmd.SendObject acReport, stDocName

Exit_Command1495_Click:
Exit Sub

Err_Command1495_Click:
MsgBox Err.Description
Resume Exit_Command1495_Click

End Sub



I'm sure it involves some kind of "Current" or "Me" wording but I'm
too brain-fried to figure it out.

Thanks in advance for sharing your wisdom.

Reply With Quote
  #2  
Old   
Ira Solomon
 
Posts: n/a

Default Re: Email function - restricting reports to current record - 05-13-2006 , 11:34 AM






Hi:
Don't do it in code.
Assume your form is named MyForm.
On the form there should be a field with the key for the current
record. If not, make one (you can make it invisable).
Then base the report on a query that uses the key field on the form as
a criteria.
So in the query you would have the key field, and in the criteria you
would have:
Forms!MyForm!CurKey

The "Curkey" is the name of the field in the form.
This works and the code needs no change.

Good Luck
Ira Solomon

On Sat, 13 May 2006 04:28:18 -0400, The Woo <***.www.co.> wrote:

Quote:
Hello all!

I used the Command Button Wizard to put a button on my form which will
email a report to my colleague. Just one prob: it will email all the
records.

How do I restrict the report to just the currently-selected record?

Here's the code as it is now:



Private Sub Command1495_Click()
On Error GoTo Err_Command1495_Click

Dim stDocName As String

stDocName = "rptFinancials"
DoCmd.SendObject acReport, stDocName

Exit_Command1495_Click:
Exit Sub

Err_Command1495_Click:
MsgBox Err.Description
Resume Exit_Command1495_Click

End Sub



I'm sure it involves some kind of "Current" or "Me" wording but I'm
too brain-fried to figure it out.

Thanks in advance for sharing your wisdom.

Reply With Quote
  #3  
Old   
The Woo
 
Posts: n/a

Default Re: Email function - restricting reports to current record - 05-16-2006 , 12:52 AM



On Sat, 13 May 2006 12:34:31 -0400, Ira Solomon
<isolomon (AT) solomonltd (DOT) com> wrote:

Quote:
Hi:
Don't do it in code.
Assume your form is named MyForm.
On the form there should be a field with the key for the current
record. If not, make one (you can make it invisable).
Then base the report on a query that uses the key field on the form as
a criteria.
So in the query you would have the key field, and in the criteria you
would have:
Forms!MyForm!CurKey

The "Curkey" is the name of the field in the form.
This works and the code needs no change.

Thanks Ira. Your solution cuts right to the heart of things. I always
feel guilty leaning on the experts here, so I always try for three or
four days (as penance) before asking for help. None of my Google
searches or forays into VB was as helpful as your response! Keep up
the good work.

Fred M. (the Woo)


Reply With Quote
Reply




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 On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.