473,657 Members | 2,587 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3158
> 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.co m> 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.RunComman d acCmdAppMinimiz e.

Feb 6 '06 #4
deko <de**@nospam.co m> 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.RunComman d acCmdAppMinimiz e.

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 "GetTempPat hA" (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(Cance l As Integer)
Dim xlapp As Excel.Applicati on
strTempGif = TempPath & "MyChart.gi f"
Set xlapp = New Excel.Applicati on
xlapp.Workbooks .Open "C:\Book1.x ls"
xlapp.ActiveWor kbook.Worksheet s("Sheet1") _
.ChartObjects(1 ).Chart.Export _
fileName:=strTe mpGif
DoEvents
Set xlapp = Nothing
End Sub

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

Feb 7 '06 #6
deko <de**@nospam.co m> 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
5687
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: ----------------------------------------------------- On Error GoTo ErrReport
2
423
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 like them to go down the spreadsheet rather than across for ease of input for the user TIA Tony Williams
3
3325
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 (as EXCEL). So the memory has been taken by excel objects and memory is being full. i want to delete or kill this objects which are in memory. i wrote the code as 'myexcel.quit()' , myexcel=nothing. but still it is in memory. pls tell me how to...
2
2984
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 the form. The problem is only in that I don't want to answer the question from Excel "Do you want to save (y/n):". I just want to print the sheet. Can I do this in such a way that excel will not prompt me to save? I don't see any alternative...
4
7946
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 out after googling for the last 3 days. I have written a large python script which inside of it creates an Excel table, the name of this file and how many objects can change for each project i run.
5
15108
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 order to demonstrate the use of Excel Functions within the context of Access, I performed the following steps in sequence: Created a Public Function called fStripNonPrintableCharacters() which will encapsulate the logic for executing the Excel...
1
1809
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 the yvalues from the output query in excel sheet and graph column B vs Column A... For the graphing part of the code this is what i have:
16
5171
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 Storage_Click() On Error GoTo Err_Storage_Click
7
4654
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 do is design a command button that will kick out the information that is stored in the subform to an excel document. Ideally I would like to use the DoCmd.OutputTo function so that the user could choose their output type, but right now I'll take...
0
8394
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8306
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8825
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8605
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7327
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4152
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.