473,660 Members | 2,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Print Report Based on Query of External Database

194 New Member
Hi Everybody,

I have an external database called Patients.mdb where i made a query called qryAdmissionDet ails. now i want to run this query on a report of another database called PatientDetails. mdb. how i can do this? can this be done by setting the recrodset of a continuous form to the recordset of qryAdmissionDet ails and then printing that continous forms to a report? please tell me how i can do this.

code for setting the recordset of the form to the query's data

Dim dbPatients As Database
Dim rsPatients As Recordset

Const strDBPath = "C:\Patients.md b" ' external database
Set dbPatients = OpenDatabase(st rDBPath, False, True, ";PWD=abc")

Set rsPatients= dbPatients.Open Recordset("SELE CT * FROM qryAdmissionDet ails", dbOpenSnapshot) 'Admissions is a table where records of admitted patients is entered

Set Me!Recordset = rsPatients ' form on PatientDetails. mdb


Thanking you.

Regards
Mar 19 '08 #1
1 2127
PianoMan64
374 Recognized Expert Contributor
Hi Everybody,

I have an external database called Patients.mdb where i made a query called qryAdmissionDet ails. now i want to run this query on a report of another database called PatientDetails. mdb. how i can do this? can this be done by setting the recrodset of a continuous form to the recordset of qryAdmissionDet ails and then printing that continous forms to a report? please tell me how i can do this.

code for setting the recordset of the form to the query's data

Dim dbPatients As Database
Dim rsPatients As Recordset

Const strDBPath = "C:\Patients.md b" ' external database
Set dbPatients = OpenDatabase(st rDBPath, False, True, ";PWD=abc")

Set rsPatients= dbPatients.Open Recordset("SELE CT * FROM qryAdmissionDet ails", dbOpenSnapshot) 'Admissions is a table where records of admitted patients is entered

Set Me!Recordset = rsPatients ' form on PatientDetails. mdb


Thanking you.

Regards
As long as the two tables have the exact same structure and Schema, then all you would have to do is simply set the Form recordset to the new MDB file.

If the structure is different, then you'll have to create a new form and display data specific to that database.
Mar 20 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2006
by: Sherwood Botsford | last post by:
I'm new to access. I have an orienteering database that has information about locations all over the map. Each location has 0-N clues I've worked up a report that will print the locations, with their associated information, and the clues that go with that.
3
16827
by: Glenn Zamora | last post by:
I am new to MS Access. I have created a simple entry form to track patient information. I have also created a Patient Report that prints Patient Information with a standard disclaimer statement. I added a print button to my entry form hoping that the patient information that I enter will merge with the Patient Report however I must be missing a step because when I click on the print button it prints all patients in the database. Is there...
2
14115
by: Dean Slindee | last post by:
Anybody written code in VB.NET to: 1) show a print preview window of reports already written and stored in an Access 2002 database; or 2) execute the print of a report stored in an Access 2002 database? Thanks, Dean Slindee
2
9341
by: amith.srinivas | last post by:
Hi all, From a word macro in VBA, I am trying to create a report in access DB. The report is based on a query with a parameter. I am using Set rpt = Application.CreateReport rpt.RecordSource = <<Query_Name>> Once I create the report, I m trying to create labels to display the Report title in the Report Header section.
6
9413
by: Dave | last post by:
On my form I have combo boxes. These combo boxes, after updating them, populate respective listboxes that are located below the combo boxes on the same form. I am trying to use a "generate report" button located on my form to print all of the list box values (that have been updated via selection from combo boxes) from the form to the report. I've tried using a macro with the code: Macro Name: cmdGenerateReport : On Click Action:...
6
2562
by: alphaomega3 | last post by:
I'm back with a new set of problems with the old NCR database from a year ago. I have a form that is for Nonconformance Entry. In the process of entering this form if the supplier for the nonconforming material is external the entry person clicks a checkbox and a lookup is performed to a pass thru query. Currently, we print off a Nonconformance report after all data is entered. We have added a new form for external vendors call a...
3
3898
by: sconard | last post by:
I have a subform in datasheet view that is the result of a complex vba custom query with a number of parameters. I would like to place a button on the parent form to print the datasheet view as a report or generate a report from recordset that created the datasheet view. I do not see the ability to create a report from a form. How is this best achieved? Thank You
12
3529
by: Studiotyphoon | last post by:
Hi, I have report which I need to print 3 times, but would like to have the following headings Customer Copy - Print 1 Accounts Copy - Print 2 File Copy -Print 3 I created a macro to print the report three times, but do not know how
11
7321
by: Gord | last post by:
When I open a certain report, it runs some code that generates the records that will be displayed in that report. This works fine. When I go to print preview the report it appears that the code is run again? This is causing certain error problems. 1 Why does the code run for a print preview when the report already exists? 2 What command do I use in code to find out if a report (or any other object for that matter) is already...
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8341
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8539
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7360
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4176
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4342
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2759
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1982
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.