By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,471 Members | 2,277 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,471 IT Pros & Developers. It's quick & easy.

Print Report Based on Query of External Database

100+
P: 194
Hi Everybody,

I have an external database called Patients.mdb where i made a query called qryAdmissionDetails. 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 qryAdmissionDetails 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.mdb" ' external database
Set dbPatients = OpenDatabase(strDBPath, False, True, ";PWD=abc")

Set rsPatients= dbPatients.OpenRecordset("SELECT * FROM qryAdmissionDetails", 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
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 374
Hi Everybody,

I have an external database called Patients.mdb where i made a query called qryAdmissionDetails. 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 qryAdmissionDetails 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.mdb" ' external database
Set dbPatients = OpenDatabase(strDBPath, False, True, ";PWD=abc")

Set rsPatients= dbPatients.OpenRecordset("SELECT * FROM qryAdmissionDetails", 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

Post your reply

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