![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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. |
#3
| |||
| |||
|
|
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 |
![]() |
| Thread Tools | |
| Display Modes | |
| |