Hello all,
I've set up protected Excel sheets that users can paste data into. I then need to be able to pull the data they paste into multiple access tables and then reset the Excel spreadsheet back to the template. For example, the first few columns go to the first table, the next 3 into a second table and so on. Is this possible? I can't think of a way to do it. Thanks in advance for all your help!
5 6387
Here is what I came up with...
1) As could be expected, your field names and data types should be consistent between the Excel Spreadsheet and the Access Tables.
2) You will likely need to have some sort of module to be able to code a pause between trips out to the spreadsheet to get another column. I used this one by Dev Ashish .
3) Here is the code I used... - Private Sub Import_Click()
-
DoCmd.TransferSpreadsheet, acSpreadsheetTypeExcel9, "tblImport1", "C:\Spreadsheet.xls", True, "A:A"
-
'Transfers column A from your spreadsheet to the 1st table in your database
-
Call sSleep (500)
-
DoCmd.TransferSpreadsheet, acSpreadsheetTypeExcel9, "tblImport2", "C:\Spreadsheet.xls", True, "B:B"
- Transfers column B from your spreadsheet to the 2nd table in your database
-
Call sSleep (500)
-
DoCmd.TransferSpreadsheet, acSpreadsheetTypeExcel9, "tblImport1", "C:\Spreadsheet.xls", True, "C:C"
- Transfers column C from your spreadsheet to the 3rd table in your database
-
Call sSleep (500)
-
DoCmd.TransferSpreadsheet, acSpreadsheetTypeExcel9, "tblExcelTemplate", "C:\Spreadsheet.xls", True
- Transfers a table in your database with the spreadsheet's column names and no data, back to your spreadsheet.
- End Sub
Hope this helps.
Brad.
Brad,
Thanks for that bit of code. That definitely helped. However, it led me to another problem. The ID is set by an autonumber in the first table things are copied into. However, this ID needs to be duplicated in all the other tables. The reason for this is because users run reports that pull information together from the various tables in stages, so access needs to know what entries go with what entries in each table. I can't find a way to get access to duplicate the ID from the first table in the other tables. To follow is the specific (simplified) example: Table 1
ID, Var 1, Var 2
Value:
1, X1, X2
2, Y1, Y2 Table 2
ID, Var 3, Var 4
Value:
1 (assigned from table 1), X3, X4
2 (assigned from table 1), Y3, Y4
Report:
X1, X2, X3, X4
Y1, Y2, Y3, Y4
Thanks again for your help and any ideas on this problem are equally appreciated.
That's a tough one. Since you want all of the tables to share the same ID number, using an AutoNumber on any of them would be illadvised because that number can reset itself, which would cause your data not match up anymore.
I was trying to think of a way to use the date in combo with something else from the record to be the unique ID. So far no luck. I'll keep thinking about, but maybe one of the experts has some thoughts on this one.
Brad.
Hey Brad,
I just wanted to let you know I ended up figuring it out and wanted to thank you for your help and guidance. The way I did it was using a DoCmd to import the spreadsheet directly to a query which split the information up. Thank you again for all your help.
Glad you found a solution!
Brad.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Edward S |
last post by:
I budget for a Project in an Excel sheet as illustrated below. The
months below are usually a 2 year period i.e. 24 months, though it
could be over 24 months depending upon a Project. I then...
|
by: Darren |
last post by:
I have been attempting to create a reservation planning form in excel
that imports Data from an Access database and inserts that information
automaticly into the correct spreed sheet and the...
|
by: Arno R |
last post by:
Hi all,
I will have to handle a lot of really 'nice' data in a LOT of Excel sheets. It is all about music files (Billboard top 100)
I am afraid there really is a sheet for every year ... (Don't...
|
by: Hi5 |
last post by:
Hi,
I am new to access I usedto work in Oracle and Mysql.
I am after a way that enables me to populate a database I designed in
access with lots of data which can be sorted in excel sheets,
...
|
by: jillandgordon |
last post by:
I am trying to import an excel file into Access 97. It looks perfectly all
right but, every time I try to import it, I get to the lst step and am told
that it was not imported due to an error. ...
|
by: Conrad F |
last post by:
Hello All,
I know how to import a specific named excel sheet into a datagrid
using ADO.NET by setting up a JET connection and then SELECTing data
from the sheet. However, for a real world...
|
by: Patrick B. |
last post by:
I have an existing excel spreadsheet that my customers
MUST continue using. There are 5 different specially
formatted cell groups (tables) on one sheet where the use
can enter data. The data in...
|
by: DrewYK |
last post by:
I have the project that may never end in front of me.
I am creating a routine that will take SpreadSheets from Excel and
bring them into Access.
I am not using any "DoCmd"s because the goal...
|
by: Harshe |
last post by:
hello all,
I am trying to code, but i am just stuck after importing one sheet. so here is the gist of what i need help with.
In a workbook at the start of the year (january) i will have 4...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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,...
|
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...
|
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...
|
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,...
|
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...
| |