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

Embedded Spreadsheet in an Access form. How to save data.

I have been working on an Access app that takes info from a file and writes
it to a spreadsheet on a form, simultaneously saving the spreadsheet to
Excel. I got the idea that the same concept could work in reverse, i.e. we
have a cost model written in Excel that calculates the profitability of
customer accounts based on several inputs and they need to be updated at
least once per year. These cost models sit on lots of people's hard drives,
but there is no central repository of information from it or even a log to
see if the cost models have been run recently.

I would like the user to be able to open the model from within a form,
update it, and when they save it, have the app write key information to a
table (maybe customer name and id, total cost, total revenue, margin and
last date the model was run). That information would be linked to other
customer info as part of and MIS system.

Is there an easy way to do this? Is it simply a matter of storing specific
cell references in memory and then writing these to a table or is there a
better way of handling this?

Nov 12 '05 #1
8 1558
<<and when they save it, have the app write key information to a
table (maybe customer name and id, total cost, total revenue, margin and
last date the model was run)>>

Then you'll have to write DAO or ADO code in the Excel file that runs
appropriate SQL statements against the Access database. You'll have to pray
that the Access database is always located i nthe same folder, too, or at least
provide a mechanism for the user to "search" for the Access database if it's
not found in the last location (and save the location on a hidden sheet)

This is all doable, but you're heading down a rough road. Instead, if I were
you, I'd do my darnedest to replace the Excel application completely with
Access.

What exactly is Excel giving you that Access can't?
Nov 12 '05 #2
"DCM Fan" <dc****@aol.comSPNOAM> wrote in message
news:20***************************@mb-m01.aol.com...
<<and when they save it, have the app write key information to a
table (maybe customer name and id, total cost, total revenue, margin and
last date the model was run)>>

Then you'll have to write DAO or ADO code in the Excel file that runs
appropriate SQL statements against the Access database. You'll have to pray that the Access database is always located i nthe same folder, too, or at least provide a mechanism for the user to "search" for the Access database if it's not found in the last location (and save the location on a hidden sheet)
Well I do not see that as a problem since I planned to use an embedded
spreadsheet (FormulaOne ActiveX) on a form *within* Access.
This is all doable, but you're heading down a rough road. Instead, if I were you, I'd do my darnedest to replace the Excel application completely with
Access.

What exactly is Excel giving you that Access can't?

The model is already in existence and is fully debugged plus users are
familiar with the interface. I simply want to be able to allow them to do
pretty much what they have always done, but post the information to a
database upon completion so the managers are able to query a database to see
if the models are up-to-date. If an account was $5mm one year but $12mm the
next, it might need to be re-priced. With this approach, I could compare
current asset levels with those of a prior time frame and determine whether
the cost model needs to be updated.
Nov 12 '05 #3
<<Well I do not see that as a problem since I planned to use an embedded
spreadsheet (FormulaOne ActiveX) on a form *within* Access.>>

Well, I've never used that 3rd party ActiveX control, so maybe it inherently
"knows" the database path of an embedded object...good for you if it does.

<< I simply want to be able to allow them to do
pretty much what they have always done, but post the information to a
database upon completion so the managers are able to query a database to see
if the models are up-to-date. If an account was $5mm one year but $12mm the
next, it might need to be re-priced. With this approach, I could compare
current asset levels with those of a prior time frame and determine whether
the cost model needs to be updated.>>

Then why do you need to embed the Excel files? Can't the Excel files live their
own lives, doing their own things, with VBA code that populates external
databases as needed?

I'm not seeing the value-add of having it embedded yert, other than
gee-whiz-bang reasons, and the fact that you may have already paid for a
control you want to use. All you're doing is bloating the Access database, and
increasing its risk of failure. (Although Access has functionality that you
might think is cool, it's not really what Access is for...)

I read the 2-page datasheet at xlsoft.com, and they do not even mention if the
Formula One compnents allows embedded Excel objects that contain VBA! You'd
think that would be front-and-center.

Than again, you say these model already exist (as normally-created Excel file,
I assume), so I don't even understand why you need Formula One ActiveX at
all...

At any rate, no embedded object that I know of "knows" that it's embedded, and
"knows" what its parent object is, when it's activated. So when I imagine your
embedded Excel object on an Access form, and that Excel object has a macro
button in it, and you "open" the object (you'll have to open the Excel object
to change anything in it), the code behind the Excel button has no idea that it
was launched from an Access form....so it won't know WHERE the database is!

Now, if you're using a BOUND object frame, and LINKING to an Excel file, at
least maybe you could add code behind the Excel button that looks for the
database of a certain name in the same folder as the Excel file...that would
work.

But I'm still not sold on this whole idea. If you work it out, I'd like to see
your defintion of "success."
Nov 12 '05 #4
"DCM Fan" <dc****@aol.comSPNOAM> wrote in message
news:20***************************@mb-m29.aol.com...
Then why do you need to embed the Excel files? Can't the Excel files live their own lives, doing their own things, with VBA code that populates external
databases as needed?
Well, this nextpart of your reply changes my thinking: At any rate, no embedded object that I know of "knows" that it's embedded, and "knows" what its parent object is, when it's activated.
I was assuming that with the object embedded, it would be aware of the
underlying database (I'm obviously not an ActiveX expert). I have done some
work with automation, but had so many problems with "ghost' Excel objects in
memory, that I wanted to avoid using Excel to the extent possible.

snip
Than again, you say these model already exist (as normally-created Excel file, I assume), so I don't even understand why you need Formula One ActiveX at
all...
Basically, I wanted my application to be run from within Access, but using a
spreadsheet since that is what is familiar to the users. Running the Excel
models as stand-alone apps is what is done now. I want to launch it from
Access and capture data back whenever the spreadsheet is saved. Obviously,
I do not have a good understanding of how this might occur. But the idea is
that if they want to run the Excel cost models, they must initiate the
request from within Access (maybe VBA and automation from a command button).
When they finish and save, Access gets the current date and key data. Then
I have something useful in Access that management can use.
But I'm still not sold on this whole idea. If you work it out, I'd like to see your defintion of "success."


Developing the concept is one thing, but how I will handle the
implementation is still a mystery to me.
Nov 12 '05 #5
<<But the idea is that if they want to run the Excel cost models, they must
initiate the request from within Access (maybe VBA and automation from a
command button). When they finish and save, Access gets the current date and
key data. Then I have something useful in Access that management can use.>>

Then I recommend just storing the paths to the Excel docs in the Access
database, with a "Launch" button that will open them via Automation. Each of
the Excel docs will have to be re-engineered with a command button of their
own. (Although if you were really into it, you could use Automation to create a
command button on the fly, and attached code to it too!)

During the Automation whilst opening the workbook, you could also populate a
hidden worksheet with the path to the database that just launched the
automation...now you know where it is, and it can change at will.

I would also set a global variable at the time of Open, too, so that you know
that the book was opened by Automation....that way, you can prevent the user
from exiting Excel without clicking your button to get back to Access....and
when they click the button, run some DAO SQL statements to update the target
database (which you'll know b/c you stored the path on the hidden worksheet
when you opened the book)

There ya go...just using Automation...NO EMBEDDED OBJECTS!!!

Nov 12 '05 #6
"DCM Fan" <dc****@aol.comSPNOAM> wrote in message
news:20***************************@mb-m23.aol.com...
<<But the idea is that if they want to run the Excel cost models, they must initiate the request from within Access (maybe VBA and automation from a
command button). When they finish and save, Access gets the current date and key data. Then I have something useful in Access that management can use.>>
Then I recommend just storing the paths to the Excel docs in the Access
database, with a "Launch" button that will open them via Automation. Each of the Excel docs will have to be re-engineered with a command button of their own. (Although if you were really into it, you could use Automation to create a command button on the fly, and attached code to it too!)

During the Automation whilst opening the workbook, you could also populate a hidden worksheet with the path to the database that just launched the
automation...now you know where it is, and it can change at will.

I would also set a global variable at the time of Open, too, so that you know that the book was opened by Automation....that way, you can prevent the user from exiting Excel without clicking your button to get back to Access....and when they click the button, run some DAO SQL statements to update the target database (which you'll know b/c you stored the path on the hidden worksheet when you opened the book)

There ya go...just using Automation...NO EMBEDDED OBJECTS!!!

Thanks. That sounds like a fairly clear approach.
Nov 12 '05 #7
You can use WIthEvents on the Excel object and sink any of the events
exposed by the Excel Automation interface. I'd guess that the File Save
and File Close methods are exposed. If you search on GoogleGroups I'm
sure you could find some canned code.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Colleyville Alan" <ae***********@nospam.comcast.net> wrote in message
news:qvXkc.10669$kh4.673935@attbi_s52...
"DCM Fan" <dc****@aol.comSPNOAM> wrote in message
news:20***************************@mb-m29.aol.com...
Then why do you need to embed the Excel files? Can't the Excel files live
their
own lives, doing their own things, with VBA code that populates
external databases as needed?


Well, this nextpart of your reply changes my thinking:
At any rate, no embedded object that I know of "knows" that it's embedded, and
"knows" what its parent object is, when it's activated.
I was assuming that with the object embedded, it would be aware of the
underlying database (I'm obviously not an ActiveX expert). I have

done some work with automation, but had so many problems with "ghost' Excel objects in memory, that I wanted to avoid using Excel to the extent possible.

snip
Than again, you say these model already exist (as normally-created
Excel file,
I assume), so I don't even understand why you need Formula One
ActiveX at all...


Basically, I wanted my application to be run from within Access, but

using a spreadsheet since that is what is familiar to the users. Running the Excel models as stand-alone apps is what is done now. I want to launch it from Access and capture data back whenever the spreadsheet is saved. Obviously, I do not have a good understanding of how this might occur. But the idea is that if they want to run the Excel cost models, they must initiate the
request from within Access (maybe VBA and automation from a command button). When they finish and save, Access gets the current date and key data. Then I have something useful in Access that management can use.
But I'm still not sold on this whole idea. If you work it out, I'd
like to see
your defintion of "success."


Developing the concept is one thing, but how I will handle the
implementation is still a mystery to me.


Nov 12 '05 #8
"Stephen Lebans" <Fo****************************************@linval id.com>
wrote in message news:3u*********************@ursa-nb00s0.nbnet.nb.ca...
You can use WIthEvents on the Excel object and sink any of the events
exposed by the Excel Automation interface. I'd guess that the File Save
and File Close methods are exposed. If you search on GoogleGroups I'm
sure you could find some canned code.


Yep, I've used close and write, though I'm guessing that write is a VB
function not really an Excel method, but it works.
Nov 12 '05 #9

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

Similar topics

11
by: Mark Yudkin | last post by:
The documentation is unclear (at least to me) on the permissibility of accessing DB2 (8.1.5) concurrently on and from Windows 2000 / XP / 2003, with separate transactions scope, from separate...
2
by: Colleyville Alan | last post by:
I have been working on an application that queries data from Access, loads it into an array, and then writes it to an Excel spreadsheet. I use the array approach to have fine control over spacing,...
8
by: Colleyville Alan | last post by:
I have been working on an Access app that takes info from a file and writes it to a spreadsheet on a form, simultaneously saving the spreadsheet to Excel. I got the idea that the same concept...
0
by: kate funnell | last post by:
Dear All I want to open an excel template from a specific location i.e. C:\MyDocuments\Sheet1 using a button on a form in access 2000. Obviously when the spreadsheet opens it will re-name...
1
by: veens-zevenhonderdvijf | last post by:
Hi, I want to show an excel-graphs in one of my access-forms. The problem is how to refer to an embedded excel-file in my form. I can refer to an external excelfile (see below) an do some test...
13
by: Dixie | last post by:
How do I, in VBA from an access form module, add 5 rows to the top of a spreadsheet called MySpreadsheet.xls. The worksheet is called MyWorksheet and there is already data in the first 5 rows. I...
3
by: Brooke | last post by:
I am new to ASP.NET, but have been programming for about 14 years (C# about 2 years). My manager asked me to develop a web application that would allow employees to view a spreadsheet that is used...
1
by: jimc52 | last post by:
I work for a food company where we design new food products. I have an Access Database where I keep track of all the ingredents we use in the company, and add new ones daily. What I want to do is...
3
by: GH | last post by:
Does anyone know how I can access (using OleDbConnection, I presume) a spreadsheet embedded in a cell of another spreadsheet (with vb.net)? Thanks, GH
1
by: platski | last post by:
I have learned a bit about vb recently and have been using it for my job, I still have questions and dont know how to do many things yet. I appreciate your time and efforts and hopefully I can...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.