473,320 Members | 1,884 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 2102
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

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

Similar topics

2
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,...
3
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...
2
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...
2
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 =...
6
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...
6
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...
3
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...
12
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...
11
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.