What you would want to do is adda button to your form. Pull up the record
you want on the form (Mr. Smith for example) and then click the button. I
would clal the button something like "print envelope" or "single envelope".
If you add the button to your form using the wizard, you can select to have
it print your envelope report. Then, you can go back and modify the code
that the wizard created so that it will only print the current record.
In the button's code, you would need to put something similar to the
following...
Private Sub cmdPrint_Click()
Dim strWhere As String
If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If
If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[ID] = " & Me.[ID]
DoCmd.OpenReport "MyReport", acViewPreview, , strWhere
End If
End Sub
Notes: If your primary key is a Text type field (not a Number type field),
you need extra quotes: strWhere = "[ID] = """ & Me.[ID] & """"
If you want the report to print without preview, replace acViewPreview with
acViewNormal.
Post back if you need more help.
> I am brand new to Access. I just took over a job that the previous person
> was using Panorama converted to be able to use on Windows. (It's a Mac
[quoted text clipped - 21 lines]
> everything switched by the end of June to start our new fiscal year with
> Access. I haven't even started that math part yet.
I am so new that this went over my head, at first. But after playing around
with it, I got the first part done. I have a button, but, like you said, it
prints all of the envelopes, not just the one that I want. So, I am looking
at the code that the wizard attatched to the button and I can't figure out
what you mean by modify the code. Am I supposed to copy and paste everything
that you said earlier or am I just modifying some of the code lines. If I am
copying and pasting, does it go above or below what is already there? Am I
supposed to make any changes to your code?
As an after thought, I decided to paste what I have so far.
Option Compare Database
Private Sub print_envelope_Click()
On Error GoTo Err_print_envelope_Click
Dim stDocName As String
stDocName = "Envelope"
DoCmd.OpenReport stDocName, acNormal
Exit_print_envelope_Click:
Exit Sub
Err_print_envelope_Click:
MsgBox Err.Description
Resume Exit_print_envelope_Click
End Sub
Thanks for taking the time to help someone that knows absolutely nothing.
> What you would want to do is adda button to your form. Pull up the record
> you want on the form (Mr. Smith for example) and then click the button. I
[quoted text clipped - 69 lines]
> > everything switched by the end of June to start our new fiscal year with
> > Access. I haven't even started that math part yet.
Rick B - 20 Apr 2005 14:37 GMT
You would need to change your code as follows. You will need to replace the
[ID] with the name of your field that identifies the person to print. The
first [ID] is the name of the field on the report that contains the key
value. The second part Me.[ID] represents the field on the form you have
open.
Private Sub print_envelope_Click()
Dim strWhere As String
If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If
If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[ID] = " & Me.[ID]
DoCmd.OpenReport "Envelope", acViewPreview, , strWhere
End If
End Sub
> I am so new that this went over my head, at first. But after playing around
> with it, I got the first part done. I have a button, but, like you said, it
[quoted text clipped - 101 lines]
> > > everything switched by the end of June to start our new fiscal year with
> > > Access. I haven't even started that math part yet.