Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing a single record

Status
Not open for further replies.

Digsys

Technical User
Jun 27, 2002
170
0
0
AU
I have a form with an SQL statement for the recordsource. I then have a button to print a record. It does an Openreport operation and the "open" event of the report sets the same recordsource as that of the form. How can I print say the 4th record only ??
Any help would be appreciated as I am new to this work
 
You can use a Where statement, for example:

[tt]DoCmd.OpenReport "rptReport",acPreview,,"ID=" & Forms!frmForm!ID[/tt]

It is also possible to use PrintOut to print a specific page.
 
I have used the field [Familyname] in the where statement as follows:
DoCmd.OpenReport "Envelope", acViewPreview, , "FamilyName=" & Forms!PrintEnvelope!Familyname
but I get a popup window titles with the Name of a famil from the database and asking me to enter a parameter value
Any Ideas ?
 
I guess FamilyName is a text field, so:

"FamilyName='" & Forms!PrintEnvelope!Familyname & "'"

You need to ensure that FamilyName is included as a field in the RecordSource of the report.
 
Thanks so much, it was a text field and Problem is now solved
 
Is there a reason why you are not passing a parameter to the stored procedure using the input parameters and opening the report without the parameter ? It is much more flexible.

Remember when... everything worked and there was a reason for it?
 
It may be a solution, but I am not familiar with it. Can you give a few details or an example?
 
1) In the stored procedure as the 1st line, enter in
@FamilyName varchar(50)
2) In the report properties under the data tab, on the last line will be input paramters, enter in
@FamilyName = Forms!PrintEnvelope!Familyname
3) In the vb code, enter in
DoCmd.OpenReport "Envelope", acViewPreview

That should do it.

If you want more parameters, just seperate by commas in the stored procedure and the input parameter line.

There is a lot you can do, passing parameters this way.

Let me know how you make out.

Remember when... everything worked and there was a reason for it?
 
GShen, I think Digsys means Access Jet SQL.
 
Remou,
I am not sure what ACCESS JET SQL means and I don't know how would know that from his question. Sorry Digsys for the misinformation.

Remember when... everything worked and there was a reason for it?
 
GShen, I am sorry if I have offended, it is just that the syntax is a little different in Access, instead of:
@FamilyName varchar(50)

One would say:
PARAMETERS FamilyName Text ( 50 );
 
Remou,
No problem. Like I said, I still don't know how you knew that from Digsys's question. I don't want to respond to someone else the same way not knowing if they are talking about ACCESS JET SQL or just simply stored procedures. Digsys,
If you have info. on this please inform here. Is your ACCESS DB an MDB or ADP?
Thanks,

Remember when... everything worked and there was a reason for it?
 
Thanks gshen for you time and concern, I am using access MDB and the "Parameters" seem familiar. I will experiment with that approach
 
Digsys,
The code I gave you is for ADP's. I am not sure how this would work for an MDB as Remou noted, it probably does not.
...... better luck next time.

Remember when... everything worked and there was a reason for it?
 
It is possible to discover from a members profile their areas of interest.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top