Push Data From Current Record In Form Into A New Excel File, Using Excel Template
Sep 10, 2007
I searched the archive and didn't find quite what I was looking for, so..
I have an Excel 2003 spreadsheet work-in-progress being used as a template (developed by others) to prepare project cost estimates in a complex regulatory environment. We are 'modelling on the fly' for a number of projects until we are comfortable with the estimate model, after which time I intend to incorporate our 'stable' estimate methodology into Access. Meanwhile, I am 'stuck' with the Excel spreadsheet.
I have a project tracking database (Access 2003), and I want to be able to track my estimates. I do NOT want to embed my spreadsheets into the db, just a filelink. There can be more than 1 estimate per project.
Ideally, the user should be able to define a project in the Access db (or select one already defined) and click a 'make estimate' button, which would generate a new Excel file in a predefined directory (based on the present version of the .xlt file), give it an appropriate filename (based on the Access ProjectID and estimate sequence number for that project if there were others already), open up that workbook in Excel, and then autopopulate some cells based on information showing on the original form in Access!
A separate button for 'Open existing estimate' will eventually be required, but I think I could do that if I can get someone to walk me through the steps required above.
I am somewhat familiar with vba in Access, but am an absolute rookie when it comes to excel.
Edit: I left out that I would also add an appropriate record to a table like tblEstimate which would contain the link(s) to the estimate(s). This table will obviously contain a FK to tblProject
Any definitive way of exporting a query to an Excel file and then saving it as a new file without saving over the original.
I've tried to remove any confidential info from the code below so it's not exactly the same.
Code: Dim XLApp As Excel.Application Dim XLSheet As Excel.Worksheet Dim tmpRS As DAO.Recordset Dim strFolder as String strFolder = ("C:Profiles"& [Name] & "")
[Code] ....
The error seems to be with the SQL statement although that may just be the first error that it got to. I read that you can't refer to a Query if it has a criteria and that you have to write the SQL directly into the code.
How much formatting can be done to a report from Access into Excel? I am trying to (or will be in the next day or so) to create a report to export data and I would like it presented in a specific format. This is hopefully to replace a spreadsheet where someone currently has to collate and re-type a load of info that has already been typed into various other spreadsheets.
Access is going to happily cope with all of those users entering their data to a table, and I would like to be able to output that data to something similar to the end result now? Is there a way to have an Excel template file and simply direct Access what to put in which cell?
So I press a button on my Form1 and my tbl_customers table is exported onto a specific sheet in a templated Excel file "customer-template" that I have created.
This file has formulas on another sheet that based on the imported data.
The file is then saved to a specific location C:AccessCustomersHistory with the file name based on a date that was criteria from my original form E.g. "customers 11-02-15"
I am able to use DoCmd.TransferSpreadsheet to export data from Access to Excel, however, I want to be able transfer data into a specific sheet within an Excel template (e.g. Tasking.xls), that will then save under a different name (e.g. Tasking 20140429.xls). The other sheets within the Excel template contain pivots etc. so they will need updating during this process. The Excel template should just close down and remain in its original format.
This process will occur once a week so the dates will have to change accordingly.
Using the code below I am able to open an explorer window from access and select most of a file path. The part I am not able to get is "LN" which is a field in my forms. I need to be able to pull the current LN number into my Modules file path. How do I do this? Is it easier to go by ID or the actual field I am looking for?
Code: Function Loan_Folder_Search3() Dim rs As Recordset Dim LN As String Dim Client_Name As String Dim RetVal As String Dim LFPath As String
[Code] ....
Currently, it keeps pulling the first record, no matter what record I'm on.
Its been a few years since I used Access, and despite searches I cant find what I'm looking for. I have a VERY simple form, with only one record on it - "address". I have some print buttons which will print that address to different size labels, and some navigation items, but only one actual record - which is "address" (in the table, this address is a MEMO)
I would like to have a command button that when clicked copies the current record, and opens an existing Excel Spreadsheet and pastes that address into (for example) cell C8
Can it be done easily? Is there a DoCmd.TransferSpreadsheet kind of secnario that works with current record only?
I have an excel file linked to a table in Access. Several fields are date data types in excel but are showing up as text fields in Access.
My real goal is to do a comparison between two tables, but only if the date of the one piece of data is newer than the other. I had planned on comparing the two date fields but even though I have formatted the date fields in my excel file to be "Date", when I look at the design view of my table it is showing up as "Text" and therefore I am unable to do this comparison.
I'm not sure if it's just something that I'm missing but maybe someone else knows an easy fix to this. I know this is probably a simple question, but I did search the forum and didn't find a thread that specifically dealt with this issue.
hi, i have struggled to import some data from an excel file into an sql database.. i have used phpmyadmin and certain code snippets but have failed miserably..
basically my excel file has lots of data, and within each cell, each bit of data is in single quotes...
eg. 'jonathan' '23' 'hardman' 'cheese'
there are no headings in the excel file (as in column or row titles) the data is just raw. once i have made the table (with the appropriate fields and datatypes for the csv file) how can i import that data into a table using ms access???
I thought i would ask this question an how to import data from excel into access.
I am using sage to invoice clients and i can output this in to excel format then i would like the best and simplest way to pull the data though into access.
The data file has column headings at the first row ie A1 though to J1 and after this is the data, i have a table setup with the relivent table names, I had thought how easy this would be, but as always this was not the case.
The outputed excel sheet will vary in location so i think i need a diolog box to select the file and then some how link it to extract the data, is this right and if so how can it be achived.
Any thoughts
Alastair
UPDATE **************************************Resolved Thanks to Pat Hartman *************************
My question is: how do I set up the table to minimize redundant data. I have several fields that match the column headings in Excel, so the data can be imported, but fields like user name, pick slot, batch # all get redundant every time I import. My file is getting unnecessarily large. I know splitting the one table into many is the right thing to do, but don't have a clue how to import the data than. any help
Hi guys, this might be a quickie, I did a quick search but couldn't find anything :/
Basically my database creates a table which some people would rather analyse within excel because they're not comfortable with access. I can get the table exporting to an xls file no problem, howeevr what I would like is for the database to export the file and open the file in excel at the same time so the user doesn't need to open up excel and find the file etc...
I'm currently working on a project within access which will allow users to select/input information in a form which will then save to the database.
What I need is to create a button on the form which will allow you to convert the data collected from the form to a custom text file template.
(Or maybe the last row added to the database. - although this may cause errors. Example: the form information doesn't save which will in turn create a text file with the data collected from the previous job)
The custom text file template should have a sentence description followed by the value recorded from the form.
Example:
1 configuration type: (data from form)
2 model type: (data from form)
3 Poc: (data from form)
And so on.
So in summary - I would be to use the form to collect the desired information which will save to the database.
Once actioned, a custom text file should be populated with the collected information (with specific data placement as per the example above)....
I'm not very experienced with Access. I'm looking for a very simple sample of how to export Query results to an Excel Template document. Especially to specific cell references. Would anyone have one to share. I'm trying to get my head around the concept first.
I may have to use Access 2000 and later versions to run the database, so do I have to cater for both DAO and ADO?
Hello, I am here back in the forum because would like some help to define a code.
Meloncolly has already helped me but I think that I have mixed up two pieces of code and cannot find the solution.
I need to export my access data to a document in excel. I will select the recorset of the data to export, using a combo box on a form named MENU.
The excel file is a template named MASTER. Before the recorset is copied, I need to make a copy of the template via code. The copy will be the document into which copy the data. Once the data is copies, I would like an input box asking users if they would like to save the new excel file and be able to name it with the name they will type in the input box.
My last problem is that the database is used by 20 users and what happens if are all exporting to the template? Will this automatically name itselft, MASTER1, MASTER 2, etc?
This is the code that I am using and tried to put together. It does copy the data into master 1 but leaves the template opened. It also tells me that there is something missing.
THanks:
Private Sub ExportToExcel_Click() Dim myid Dim obj As Object Set obj = GetObject("C: estMaster.xls") 'Dim mypath
myid = Me.[MyCombo] 'grab the three field values from the table Dim mySSN, myFirstname, myLname mySSN = DLookup("[WESSN]", "[MASTER]", "[id]=" & myid) myFirstname = DLookup("[WEFN]", "[MASTER]", "[ID]=" & myid) myLname = DLookup("[WELN]", "[MASTER]", "[ID]=" & myid)
'open excel and the required file Dim appXL3 As Excel.Application Dim blnStartXL3 As Boolean
On Error Resume Next ' Check if Excel is already running Set appXL3 = GetObject(, "Excel.Application") If appXL3 Is Nothing Then blnStartXL3 = True 'Else ' We have to start Excel ourselves Set appXL3 = CreateObject("Excel.Application") If appXL3 Is Nothing Then MsgBox "Can't start Excel", vbExclamation GoTo exit_handler End If End If With appXL3 '.Visible = True On Error GoTo Err_Handler
I have info on my access form which is located here....
Code : Forms![Front Page]![Site 2 Owner]
and here
Code : Forms![Front Page]![Postcode S2]
I would like to export this information into cells B2 & C2( individually and respectively) on the excel spreadsheet which I have saved as a template here...
Code : C:UsersmedesktopAutoExcel Auto
Is this easily achievable? To be honest I will be using it to fill in about 12 cells but how it would be done for the first two i can just modify it as necessary.
I created a form with lots of conditional formatting that did pretty much everything I wanted it to do. The only problem is that it takes about 4 full minutes for the form to open.
As an experiment I am reluctantly now trying to display the results in Excel. I have created a template xls sheet and all I want to do is, on the press of a button, copy the results from my query and paste them in to cell a1 of my spreadsheet.
I found the following code online which I am trying to adapt.
Code: Private Sub update_tracker_Click() Dim XL As Excel.Application Dim wbTarget As Workbook Dim qdfResults As QueryDef Dim rsResults As Recordset 'Set up refernce to the query to export
[Code] ....
My limited knowledge however results in a couple of errors.
The first error User defined type not defined error appears at the very first line of my code
Code: Dim XL As Excel.Application
The next error occurs as I am not sure how to reference the query to export. The query is called 2014 Resources and outputs also to a form called 2014 Resources.
What I have now is an excel template (with ~12 worksheets) that many regional offices use to enter in some lease data, from which the excel sheet creates a rental schedule and does a whole ton of calculations on that data. Some are NPV calculations, some are yields etc etc.Eventually, I would like to:
1) Enable users to fill out one of these templates, and save the data to the database (Just the inputs? All the data? My reading suggests just the inputs) 2) Use the database to produce one of these templates for any lease in our system (shouldn't be hard, from what I've read) 3) Sum up calculations from this template for many records (eg. if a tenant has many leases, what is the NPV of all of those leases, or what is the total NPV for all tenants)
I have the inputs (from Access) I will have no problem using them in the excel version, but does it make sense to use Access given that I may need to somehow be switching back and forth to get the info I want for my various reports? I am very comfortable writing macros in VBA for excel, so if that's the solution, that is no problem. I assume what I need for #1 and #2 is a macro to arrange the inputs from the excel sheet into a format that can easily be dropped into access tables and vice versa.
how i can export the data from Access to excel using Access VBA for the specified sheet using data linkage with access database. Like we used to do it manually in excel as external data from access.Like we have some codes for linking excel file to database mentioned below;
Can we have something like this to link database table in excel file automatically.So that the excel size won't be that big and also it saves processing time.
I have this UDF in my excel template that changes a set of numbers in to letters corresponding a code.
For example the code is "EUCHARISTO" it would simply mean
E=1, U=2, C=3, H=4, A=5, R=6, I=7, S=8, T=9, O=0 and by default the tenths position (".0")=X the hundredths position (.0"0") = Y and If a number repeats it becomes G.
Function LetterCode(ByVal Numbers As String, Letters As String) As String Dim X As Long Numbers = Format(Numbers, "0.00") * 100 Letters = UCase(Right(Letters, 1) & Left(Letters, Len(Letters) - 1)) If Numbers Like "*0" Then Mid(Numbers, Len(Numbers)) = "Y"
[Code] ...
Also, where best to put this code, In a query or in a module.
I have a few problems and I want them to be able to be done from switchboard:
1. Is there a way for me to export a particular report (after selecting it) to a closed excel template, that is formatted? It would open the excel template (that has a logo and column headings), export data to below the column headings, then save the file with a unique name?
2. Also, a way to import data from an excel file, after allowing the user to select file? Only data below the column headings mentioned above. Same data will be appended to existing table.
In Access column name is STKITEMNBR and data type is TEXT. 4/5 of data are numeric and 1/5 are alfa-numeric. One of data was 15E10 in Access, but was altered to 1.50E+11 when exporting out to Excel csv file. Because it was Stock Item Number it needed to stay the same as 15E10 in csv file.
I've vba in Report onformat the vba code does some data copying to External Excel file (premade by vba).Now on first run, i got success.But on opening the excel file, it showed blank space + Error"File already opened"
No White Spreadsheet is shown with data to see into file, i created new excel file in windows, and inserted the vba created/exported file as an Obj.Now Obj is showing correct and full data with spreadsheet as normal view.