469,607 Members | 2,193 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,607 developers. It's quick & easy.

Print Report Based on Query of External Database

194 100+
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
1 1792
PianoMan64
374 Expert 256MB
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.

Similar topics

2 posts views Thread by Sherwood Botsford | last post: by
2 posts views Thread by amith.srinivas | last post: by
reply views Thread by guiromero | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.