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

Need Help Printing a Report based on the Current Form Only 2

Status
Not open for further replies.

PewterSon

Technical User
Sep 27, 2002
3
GB
I am new user of access and would appreciate any help.

I have a simple database consisting of 2 tables (customers) and (service Call Enquirys).

When a customer phones up i enter the company name on the service call enquiry form and it brings up there details(name,address etc) there is then a subform for entering a callout description (order No, date of call, enginneer assigned etc)

The next step would be to print a report based on the details I have just entered to the form, this report is then sent to the relevant engineer.

The problem I have is I dont know how to print a single page report, I have tryed setting up a report but it prints all the records in the table instead of the current record.

Any help would be greatly appreciated
 
Hi

Presumably you are running the report by clicking a button on your form?

And presumably the Form contains some field to uniquely identify the record (eg the prime key)?

In you code to run the report you will have:

DoCmd.OpenReport, ...etc

well the syntax for this is:

DoCmd.OpenReport reportname[, view][, filtername][, wherecondition]

so if you put:

DoCmd.OpenReport "MyReport",acPreview,,"Key = '" & MyKey & "'"

That should do it, using your variable names of course

Regards Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
kenneth.reaySPAMNOT@talk21.com
remove SPAMNOT to use
 
Hi,

I`ve tryed what you suggested but I keep getting this Error Message(data type mismatch in criteria expression), I`ve attached the code, I could be doing it wrong.



Private Sub Command16_Click()
On Error GoTo Err_Command16_Click

Dim stDocName As String

stDocName = "Service Callout"
DoCmd.OpenReport stDocName, acPreview, , "JobID="" & JobID & """



Exit_Command16_Click:
Exit Sub

Err_Command16_Click:
MsgBox Err.Description
Resume Exit_Command16_Click

End Sub

Any Suggestions would be welcomed
Thanks for Your help

Craig Hickson
Marsden Weighing Machine Group Ltd
 
Hi

If JobId is numeric you do not need quotes round it so:
DoCmd.OpenReport stDocName, acPreview, , "JobID=" & JobID

Regards



Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
kenneth.reaySPAMNOT@talk21.com
remove SPAMNOT to use
 
Hi Ken,

Thanks very much, that worked a treat!

Best Regards,

Craig Hickson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top