Go Back   Access World Forums > Microsoft Access Discussion > Reports

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 12-12-2018, 11:00 AM   #1
PleasantB
Newly Registered User
 
Join Date: Dec 2018
Posts: 26
Thanks: 6
Thanked 2 Times in 2 Posts
PleasantB is on a distinguished road
Sizing an Access report, opened as acDialog while the main window is hidden

I already asked this question on Stack Overflow but received no responses.
I just came across this forum so thought I might have better luck here.

I am utilizing forms and reports from an old Access database in a C# application.
I do this by launching the Access database, hiding the main window, and calling a procedure that opens the form or report in a separate window.

I achieve a separate window by opening the form or report with acDialog.
A popup form also resulted a separate window but a popup report did not.

The forms are working great but I cannot get the reports to show unless I execute DoCmd.Maximize in Report_Open.

Maximizing causes the report to take up the entire screen, which is not ideal.
I wish to set the report to a size of my choosing but both the built-in Access command DoCmd.MoveSize and Windows API SetWindowPos cause the report to rejoin the main Access window, which is hidden.

I'm hoping someone can suggest a way to achieve my goal.

C# code:

Code:
    class Program
    {
        private static readonly string DbLocation = "C:\\example.accdb";

        [DllImport("user32.dll")]
        private static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);
        private const int KeyDownEvent = 0x0000;
        private const int KeyUpEvent = 0x0002;

        static void Main(string[] args)
        {
            ProcessStartInfo startInfo = new ProcessStartInfo()
            {
                FileName = GetOfficeAppPath("Access.Application", "msaccess.exe"),
                Arguments = DbLocation,
                WindowStyle = ProcessWindowStyle.Hidden
            };

            // Simulate holding the Shift key, while opening the application, to bypass startup proceedings.
            keybd_event((byte)Keys.LShiftKey, 0, KeyDownEvent, 0);
            Process process = Process.Start(startInfo);
            process.WaitForInputIdle();
            keybd_event((byte)Keys.LShiftKey, 0, KeyUpEvent, 0);

            Access.Application exampleApp = (Access.Application)Marshal.BindToMoniker(DbLocation);

            try
            {
                exampleApp.Run("OpenReport", 12345);
            }
            catch (Exception e)
            {
                MessageBox.Show($"{e.Message}\n{e.InnerException?.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                exampleApp.CloseCurrentDatabase();
                process.Kill();
            }
        }
    }

PleasantB is offline   Reply With Quote
Old 12-12-2018, 12:15 PM   #2
Uncle Gizmo
Nifty Access Guy
 
Uncle Gizmo's Avatar
 
Join Date: Jul 2003
Location: Newbury Berks UK
Posts: 10,365
Thanks: 555
Thanked 948 Times in 897 Posts
Uncle Gizmo is a jewel in the rough Uncle Gizmo is a jewel in the rough Uncle Gizmo is a jewel in the rough
Send a message via Skype™ to Uncle Gizmo
Re: Sizing an Access report, opened as acDialog while the main window is hidden

I have no idea! However I found this and wondered if it might be worth a try.

https://docs.microsoft.com/en-us/off...s.report.popup
__________________
Code:
                 |||||
               @(~^~)@
-------------oOo---U---oOo-------------
|                                     |
|      Uncle Gizmo              |
|                                     |
|                                     |
| Get $20 worth of "Nifty Code"       |
|      
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
| | Ooo | |_________________ooO____( )________| ( ) ) / \ ( (_/ \_)
Uncle Gizmo is offline   Reply With Quote
Old 12-27-2018, 01:19 PM   #3
PleasantB
Newly Registered User
 
Join Date: Dec 2018
Posts: 26
Thanks: 6
Thanked 2 Times in 2 Posts
PleasantB is on a distinguished road
Re: Sizing an Access report, opened as acDialog while the main window is hidden

I tried that originally but found that though a popup form is not hidden with the main Access window, a popup report is.
The only way I found to have a report persist when the main Access window is hidden is opening the report with WindowMode set to acDialog.

PleasantB is offline   Reply With Quote
The Following User Says Thank You to PleasantB For This Useful Post:
Uncle Gizmo (12-27-2018)
Reply

Tags
acdialog , hidden , report , size

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it possible to open a report with the Access main window hidden? Cavman Reports 6 07-18-2014 05:02 AM
Main Access Window Hidden?? That Guy Modules & VBA 3 02-11-2013 12:49 AM
Form Sizing Help when opened. Johnrg Forms 0 01-21-2009 01:24 PM
Question Access Window Sizing matthewnsarah07 General 4 06-20-2008 07:30 AM
Hidden Access Window brian0721 Forms 4 03-31-2004 08:36 PM




All times are GMT -8. The time now is 05:04 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World