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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Showing specific record in report

Status
Not open for further replies.

bajanJedi

Technical User
Feb 17, 2004
29
0
0
BB
Hi,

I have a form which contains records about patients. the primiary is PatientID and is based on the national ID number.

I have compiled a query to show the patient's bill (invoice). from this query I have created a report. i have placed a button on the same form mentioned above that will open the report. right now the button opens the report and all the records are showing.

i would like it that when the user goes to a particular record in the form, the user can click on the button to preview just that record's bill and no others.

i'm using access 2000.

 
Good post [thumbsup2]. I've had a similar problem that I made a workaround for. I built my report on a query, and made the invoice# the query criteria. When someone hits the report command button from the form, they're forced to type the invoice number.

I hope someone else posts with a more effective way to do it - I know it can be done, just don't know the right way.
 
One way to do this is to build your report on a query, and then in the form put a command button to run the report, and in the command button code put logic that selects the particular record on which you are located in the form.

An example of code behind a command button is below. This opens the report called rptMiscellaneousDonations, which is based on a query. The DoCmd line includes code which selects only the particular RecordID in question.

Dim stDocName As String
stDocName = "rptMiscellaneousDonations"
DoCmd.OpenReport stDocName, acPreview, "", "[RecordID]=[Forms]![frmMiscellaneousDonations]![RecordID]"

Hope this helps.

Tom
 
Simple. All you have to do is, in the report's record source query, enter the parameter (patient ID) that is on your form (which is displaying the record you want to show on your report. Like:

In the query's criteria section, under the column 'Patient ID':
Forms!frmyourformname![txtPatientID]

This assumes you have the 'Patient ID' somewhere on the form. In my example, I assume a text box named 'txtPatientID' is filled with the Patient's ID No.

Or, on the report's 'On Open' event, you could enter the same code.

Good luck.
 
THWatson... thank you so much. the code u gave is working nicely :) i never thought i could have finished this part of this database. here i was going around the world worrying about sql coding and that piece of code was what i needed :) thanks again.


bajanJedi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top