473,416 Members | 1,543 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,416 software developers and data experts.

Excel Output written from Access Form

I am trying to modify an Access form that allows a user to specify
the information s/he needs from a census-type database.

The form's code builds a SQL statement from the user's request, and
creates from this a record set that is used to populate a new Excel
workbook. The form's code opens the new workbook and writes both a
datasheet and a graph based on the data to it.

The graph appears on the user's screen very briefly and then
disappears as the workbook is closed as soon as all information has
been written to it.

I have tried to put a MsgBox in the Access code immediately before the
statement that closes the Excel Application. This allows the graph [&
an opportunity to switch to the Excel data screen] to remain on screen but
the Excel application is using all the screen space so that the MsgBox
that I want to function as a "return to form execution button"
remains hidden. I can return to the form by clicking its
minimized icon but I'd like that more obtrusive MsgBox button visible
for a user while s/he's seeing the Excel output.

So can I customize the Excel display screen within the Acess form?

thanks, --thelma

Feb 5 '06 #1
6 3146
> So can I customize the Excel display screen within the Acess form?

You should be able to do just about anything with Excel automation. Can you
modify whatever automation code you are using? Perhaps leave the workbook
open after populating it?

Feb 6 '06 #2
deko <de**@nospam.com> wrote:
:> So can I customize the Excel display screen within the Acess form?

: You should be able to do just about anything with Excel automation.Can you
: modify whatever automation code you are using? Perhaps leave the workbook
: open after populating it?

Yes, I could modify the code, but I don't know what I should
modify. I don't understand how leaving the workbook open will
help.

I am leaving the workbook open until the user clicks the
MsgBox button, but as s/he has to return to the Access form to see
that button the way the form works now, that open workbook
seems as much a hindrance as a help.

--thelma

Feb 6 '06 #3
> Yes, I could modify the code, but I don't know what I should
modify.
It's always a good idea to post your code when you have questions like this.
I don't understand how leaving the workbook open will
help.


As I understand it, you want the user to be able to view a chart in an Excel
worksheet after it is created via automation from Access. If you open
Excel, create the chart, and leave the workbook open, that should leave the
Excel application window on top. If not, you could minimize the Access app
window with DoCmd.RunCommand acCmdAppMinimize.

Feb 6 '06 #4
deko <de**@nospam.com> wrote:
: As I understand it,you want the user to be able to view a chart in an Excel
: worksheet after it is created via automation from Access. If you open
: Excel, create the chart, and leave the workbook open, that should leave the
: Excel application window on top. If not, you could minimize the Access app
: window with DoCmd.RunCommand acCmdAppMinimize.

Yes: this is exactly the situation I have right now. The Excel
worksheet is open over the Access application which shows as a
minimized icon.

I had written, in part:
I have tried to put a MsgBox in the Access code immediately before
the statement that closes the Excel Application....
but the Excel application is using all the screen space so that the
MsgBox that I want to function as a "return to form execution button"
remains hidden. I can return to the form by clicking its
minimized icon but I'd like that more obtrusive MsgBox button visible
for a user while s/he's seeing the Excel output.


I want the Excel worksheet display to take up less than the entire
screen, so that I can also provide user with a MsgBox for
signalling that s/he's through looking at it; then I can close
it and move on.

--thelma

Feb 6 '06 #5
> I want the Excel worksheet display to take up less than the entire
screen, so that I can also provide user with a MsgBox for
signalling that s/he's through looking at it; then I can close
it and move on.


If you want to resize the Excel application window and position it on top of
the Access application window, that will require some API programming. You
might be able to adapt code from this article:
http://support.microsoft.com/?kbid=210085

If you don't need Excel for anything but drawing the chart, you might try
using a chart report - i.e. open a new report, select the Chart Wizard and
assign your query to it. Or perhaps use some other charting component from
within Access.

Another solution is to open a popup form with code that exports the Excel
chart to a .gif and displays it in an Image control.

This code assumes the Excel chart already exists, though you could probably
incorporate any necessary automation code here as well. As you know, you
can size the chart however you want before exporting it to a gif.

The GetTempPath API function is so you don't have to worry about deleting
the gif after creating it

Private Declare Function GetTempPath Lib "kernel32" _
Alias "GetTempPathA" (ByVal nBufferLength As Long, _
ByVal lpBuffer As String) As Long

Private Const MAXPATH = 255
Private strTempGif As String

Private Function TempPath() As String
Dim strBuffer As String
Dim lngBytes As Long
strBuffer = Space(MAXPATH)
lngBytes = GetTempPath(Len(strBuffer), strBuffer)
TempPath = Left(strBuffer, lngBytes)
End Function

Private Sub Form_Open(Cancel As Integer)
Dim xlapp As Excel.Application
strTempGif = TempPath & "MyChart.gif"
Set xlapp = New Excel.Application
xlapp.Workbooks.Open "C:\Book1.xls"
xlapp.ActiveWorkbook.Worksheets("Sheet1") _
.ChartObjects(1).Chart.Export _
fileName:=strTempGif
DoEvents
Set xlapp = Nothing
End Sub

Private Sub Form_Load()
Me!imgChart.Picture = strTempGif
End Sub

Feb 7 '06 #6
deko <de**@nospam.com> wrote:
: Another solution is to open a popup form with code that exports the Excel
: chart to a .gif and displays it in an Image control.

Thanks a lot for the code that I've snipped. It would
give me good control over the display, and could be generated
after I saved the Excel output. I'll have to look at it and
decide whether to try to incorporate it.

Today I managed to get the Excel window and the Access window
sharing the screen -- it was just what I wanted, the only
problem being that I haven't the vaguest idea of what I did to
get it that way. I'm sure it had nothing to do with the code.

--thelma
Feb 7 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ian | last post by:
I have an Access97 database and I am trying to create an Excel sheet from a report within this database. I have the following code on the On Click event of a button on a form: ...
2
by: Tony Williams | last post by:
Is it possible to import a spreadsheet from Excel where the rows contain the field names rather than the columns? I'm creating an Excel spreadsheet but there are over 50 items to import and would...
3
by: hari krishna | last post by:
hi, I am generating excel reports through vb.Net. After creating excel.application and the report is generated, each report leaves Excel in memory. I can see them in task manager in Process tab...
2
by: Mr. California | last post by:
As a novice VBA programmer, I have a problem with a routine written as a click procedure from a form to open an Excel template, insert some information, print, and (ideally) return control back to...
4
by: michael.pearmain | last post by:
Hi Experts, Looking for a very quick bit on of advice on how to make some python code run. I'm a newbie to both VBA and Python, so i apologise if this is very easy but i'm about to tear my hair...
5
ADezii
by: ADezii | last post by:
Periodically, the same or similar question appears in our Access Forum: How can I use Excel Functions within Access? For this reason, I decided to make this Subject TheScripts Tip of the Week. In...
1
by: shlaga | last post by:
Hi, I have query in access that i output in excel and want to graph the output. I have written the code for this in access -> visual basic i want the code to get the range of the xvalues and...
16
by: Phil Stanton | last post by:
I have a form with a button which is supposed to open an Excel file (With lots of Macros /VBA) in it. The Excel file gets it's data from the Access program Here is the code Private Sub...
7
by: TinyTom | last post by:
I really need help with this code. I have made a pretty complicated subform that automatically updates filter criteria based off of inputs in various fields within the search form. What I need to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.