473,508 Members | 2,460 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Link Excel Data to append ACCESS table

418 Contributor
I am working on a DB to record expenses related to various grants. To record Payroll expenses I created tblPayroll with these fields:

Expand|Select|Wrap|Line Numbers
  1. PayrollID – auto / PK
  2. ECHOID – Number FK (tied to tblECHO)
  3. PayrollNo – Text
  4. PayrollDt – Date/ Time
  5. AccountID – Number FK (tied to tblAccounts)
  6. FundID – Number FK (tied to tblGrantFunds)
  7. OrgID – Number FK (tied to tblOrg) 
  8. ProgramID – Number FK (tied to tblProgram)
  9. SubClassID – Number FK (tied to tblSubClass)
  10. ProjectID – Number FK (tied to tblProject)
  11. PayAmount – Currency
Each pay period payroll data is downloaded from the server and dumped into an excel file. This spreadsheet has the following info:
Account
Fund
Org
Program
Sub Class
Project
Amount
Now if I were to append data to tblPayroll each pay period, what will be the best way to do it? Obviously I don’t want to fill in the other information (that are missing from the spreadsheet) manually. Any guidance will be much appreciated. Thanks.
May 14 '09 #1
24 6289
Denburt
1,356 Recognized Expert Top Contributor
I haven't linked to many Excel sheets but this seems like a logical path to take. I would create a form that had the pertinent fields that needs to be filled in by the user then the update query will be able to take that with the information from excel and update the Access table.
I believe the would contain the following fields. I would probably include the data from the excel spreadsheet just so you can review it.


Expand|Select|Wrap|Line Numbers
  1. ECHOID – Number FK (tied to tblECHO)
  2. PayrollNo – Text
  3. PayrollDt – Date/ Time
  4.  
May 15 '09 #2
MNNovice
418 Contributor
Denburt:

I didn't quite understand how to do this when you say:

I would create a form that had the pertinent fields that needs to be filled in by the user then the update query will be able to take that with the information from excel and update the Access table.
There is no manual data entry involved to input the payroll data. Because it's a large file that gets dumped from the server (we use accounting software PeopleSoft). What form you are refering to?

tblPayroll has GrantFundID that replaced FundID. Excel file has Fund numbers, how am I going to update tblPayroll so that it can identify the Fund number and automatically associate the Grant Number that's associated with that fund number?

This data in tblPayroll will have to be updated every two weeks as people get paid.

This is a little complex for me. Can you please give me the step by step guide to it?

Thanks.
May 15 '09 #3
Denburt
1,356 Recognized Expert Top Contributor
Start with linking in the payroll sheet and for the purpose of this example name that linked table sheet1 (so the following query will work). Start with the query when you are in design view you can click on the query button on the menu bar and change the type of query you want. Since I have a copy of your DB I helped you out a little. Start a new query and view it in SQL View, then paste the following into it and it and then view it in Datasheet or design view look it over then when you run the query it should add the records you see in Datasheet view. I think once you do that you will have a better understanding.

I also wanted to point out that you aren't using many if any of the properties for these tables and I'll tell you this, if you go step back and add the captions use the look up for your foreign keys etc. then it will help when you design your forms.
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO tblPayroll ( AccountID, GrantFundID, SubClassID, ProjectID, ECHOID )
  2. SELECT Sheet1.Account, tblGrantFunds.GrantFundID, tblSubClass.SubClassID, tblProjects.ProjectID, 12 AS [I Need to put something in here for EchoID or dont I]
  3. FROM (((Sheet1 INNER JOIN tblFunds ON Sheet1.Fund = tblFunds.FundNo) INNER JOIN tblGrantFunds ON tblFunds.FundID = tblGrantFunds.FundID) INNER JOIN tblSubClass ON Sheet1.[Sub Class] = tblSubClass.SubClassNo) INNER JOIN tblProjects ON Sheet1.Project = tblProjects.ProjectNo;
[
May 15 '09 #4
MNNovice
418 Contributor
Denburt:

Thanks I will give it a try and keep you posted.
May 15 '09 #5
MNNovice
418 Contributor
I didn't succeed. It keeps adding a field F10 at the end of the table. frmEchoEnter does not get updated. I am sure I am not doing something right but what is it - don't know.

I tried several times with the same result. Here is what I did.

1. Created a link table called Sheet1
2. Created a query based on this table called Sheet 1 Query
3. Opened the query in Design view and switched to SQL view to insert this code


Expand|Select|Wrap|Line Numbers
  1. INSERT INTO tblPayroll ( AccountID, GrantFundID, SubClassID, ProjectID, ECHOID ) 
  2. SELECT Sheet1.AccountID, tblGrantFunds.GrantFundID, tblSubClass.SubClassID, tblProjects.ProjectID, 09-064 AS [ECHOID] FROM (((Sheet1 INNER JOIN tblFunds ON Sheet1.FundID = tblFunds.FundNo) INNER JOIN tblGrantFunds ON tblFunds.FundID = tblGrantFunds.FundID) INNER JOIN tblSubClass ON Sheet1.[SubClassID] = tblSubClass.SubClassNo) INNER JOIN tblProjects ON Sheet1.ProjectID = tblProjects.ProjectNo;
4. Opened Sheet 1 Query in datasheet view
5. I get no data...

Well, that's where it ended.

Even if I succeeded I am not sure

1. How will tblPayroll be populated with these data?
2. What are the steps to take when I have payroll 9, 10 ,...keeps coming?

Thanks for your help.
May 15 '09 #6
Denburt
1,356 Recognized Expert Top Contributor
I see that I did forget to add the tblAccounts table and the appropriate relationship with the Excel sheet. Also you have changed the field echoID to represent an echo number not an ID number.

You have to remember that the Excel sheet is going to have an account No. not an ID so you need to associate all of the fields from the Excel sheet to their appropriate table by using their No or Name then you can extract the ID and return that to be inserted in the payroll table.

I also have my Excel sheet using the fields names that you posted above.

Here is an adjusted SQL statement that should work if you rename the excel sheets header information to the information above:
This spreadsheet has the following info:

Account
Fund
Org
Program
Sub Class
Project
Amount
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO tblPayroll ( AccountID, GrantFundID, SubClassID, ProjectID, ECHOID )
  2. SELECT tblAccounts.AccountID, tblGrantFunds.GrantFundID, tblSubClass.SubClassID, tblProjects.ProjectID, 66 AS ECHOID
  3. FROM tblAccounts INNER JOIN ((((Sheet1 INNER JOIN tblFunds ON Sheet1.Fund = tblFunds.FundNo) INNER JOIN tblSubClass ON Sheet1.[Sub Class] = tblSubClass.SubClassNo) INNER JOIN tblProjects ON Sheet1.Project = tblProjects.ProjectNo) INNER JOIN tblGrantFunds ON tblFunds.FundID = tblGrantFunds.FundID) ON tblAccounts.AcctNo = Sheet1.Account;
Let me know how it goes.
May 15 '09 #7
Denburt
1,356 Recognized Expert Top Contributor
@MNNovice
Not sure why your getting F10 at the end of your table did you make sure you have column titles for all the columns? If so then I wouldn't be bothered with it i have seen excel do weird things with empty columns before.

Also I may not have this right but you said this is payroll so I set the query up so that it will update the tblPayroll no other table will be updated at this time.

@MNNovice
It will be populated when you run the query we can look at that once we get this query straight.

Is the data that gets dumped in this Excel sheet added to the existing data or is it replaced by new data each month? If it is added then you will need to set the criteria in the query so it only pulls the data for that month.
May 15 '09 #8
MNNovice
418 Contributor
Denburt:

Thanks. It's almost time for me to leave for the day. But to answer your question:
Is the data that gets dumped in this Excel sheet added to the existing data or is it replaced by new data each month? If it is added then you will need to set the criteria in the query so it only pulls the data for that month.
Each payroll will be added to the existing data in tblPayroll. PayrollNo indicates the sequence of payroll in a given year. eg, 09-08 (for year 2009, it's the 8th payroll). Hope this makes sense now.

I will look at your instructions next week.

Have a good weekend and many thanks for your patience and help. Regards. MN
May 15 '09 #9
MNNovice
418 Contributor
Denburt:


I see that I did forget to add the tblAccounts table and the appropriate relationship with the Excel sheet. Also you have changed the field echoID to represent an echo number not an ID number.
It should EchoNo (text file). I can manually enter this field into the excel file each pay period. And import this data each pay period. No problem. Will this require a revision of the SQL you sent? Or am I misunderstanding something entirely?

I also wanted to point out that you aren't using many if any of the properties for these tables and I'll tell you this, if you go step back and add the captions use the look up for your foreign keys etc. then it will help when you design your forms.
Are you suggesting I should add Look Up combo boxes in table's design view? If yes, then I need to tell you that NeoPa (for a different DB) suggested that it's NOT a good practice. So I am avoiding on this new DB. Let me know.

Last week when I attempted to follow your instructions I didn't succeed. But when I hit "run" for query, I got the message that reads: "Type mismatch in expression".

Just FYI: the Excel file has these fields:

PayrollNo
PayrollDt
Account
Fund
SubClass
Project
PayAmount


Just a couple of questions before I venture into it. What happens to PayrollID, PayrollNo and PayAmount? How did these fields fit into this SQL you sent me?

Well, I ran the query and

Thanks & regards. M
May 18 '09 #10
Denburt
1,356 Recognized Expert Top Contributor
The payrollID is autonumber so that should take care of itself the Amount field in the excel sheet should be added by selecting the table (sheet1) and set the field to Amount (if that's its name) Then below in the "Append to:" you can select the amount field from tblPayroll and that should be there. You are essentially taking any data from the top fields in inserting them into the fields below in the table that is designated in the properties box under Destination Table. It appears that you may have to enter the PayrollNo as well as the echo number then use the update query.
Are you suggesting I should add Look Up combo boxes in table's design view? If yes, then I need to tell you that NeoPa (for a different DB) suggested that it's NOT a good practice. So I am avoiding on this new DB. Let me know.
Interesting I would like to hear more about this. One point of mentioning this is that it can save time when designing. Say your form is in design view and you drag a field from the field list as soon as you drop it the caption is in the label, the control will either be a list box or combo depending on what you selected and it will be ready to roll. I don't recall hearing anything negative about this practice but I don't know everything.
May 18 '09 #11
MNNovice
418 Contributor
I keep getting an error message of: Type mismatch in expression.

I checked all the fields in excel files and changed numbers to text to match the text fields in Access but still keep getting the same error message. What am I doing wrong?

This is what I have for the query

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO tblPayroll ( AccountID, GrantFundID, SubClassID, ProjectID, ECHONo, PayrollNo, PayAmount )
  2. SELECT tblAccounts.AccountID, tblGrantFunds.GrantFundID, tblSubClass.SubClassID, tblProjects.ProjectID, Sheet1.ECHONo, Sheet1.PayrollNo, Sheet1.PayAmount
  3. FROM (tblAccounts INNER JOIN (((Sheet1 INNER JOIN tblFunds ON Sheet1.Fund = tblFunds.FundNo) INNER JOIN tblSubClass ON Sheet1.SubClass = tblSubClass.SubClassNo) INNER JOIN tblProjects ON Sheet1.Project = tblProjects.ProjectNo) ON tblAccounts.AcctNo = Sheet1.Account) INNER JOIN tblGrantFunds ON tblFunds.FundID = tblGrantFunds.FundID;
Thanks.
May 18 '09 #12
Denburt
1,356 Recognized Expert Top Contributor
First the Echo table needs to be added to the query and the ID entered into the Payroll table (see tblSubclass or tblProjects in this query for an example) You must be missing something else somewhere also I think. The Excel sheet I am using does not have any fields formatted and works fine with the query you provided (Except for EchoNo). I would create a new Excel sheet then insert some data manually (pasting might also change the fields format in Excel) for a couple of records then format them one by one to suit your needs.
May 18 '09 #13
MNNovice
418 Contributor
Denburt:

I added tblECHO but the outcome remains the same. I get the same error message. Can you please have a look at the DB? (attached)
May 18 '09 #14
Denburt
1,356 Recognized Expert Top Contributor
@MNNovice
Got it

OK I opened it and looked at your query and almost all the links table to table were broken... Well I set up a NEW spreadsheet and removed the field EchoNo from the query since this is handled with EchoID and you did add (that nicely done)..
I relinked the tables in the query and I hit the same error. I then took a look in the Excel sheet and noticed that any field that has all numeric numbers in a field in Excel will need to have that formatted specifically to text if indeed the database has it stored as text for the corresponding table, once the format is changed you may need to manually re-input the data (I did). Once I did that it seemed to work nicely.
You didn't send the Excel Sheet but this should do it for you.
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO tblPayroll ( AccountID, GrantFundID, SubClassID, ProjectID, PayrollNo, PayAmount, ECHOID )
  2. SELECT tblAccounts.AccountID, tblGrantFunds.GrantFundID, tblSubClass.SubClassID, tblProjects.ProjectID, Sheet1.PayrollNo, Sheet1.PayAmount, tblECHO.ECHOID
  3. FROM ((tblProjects INNER JOIN (tblFunds INNER JOIN (tblECHO INNER JOIN (Sheet1 INNER JOIN tblAccounts ON Sheet1.Account = tblAccounts.AcctNo) ON tblECHO.ECHONo = Sheet1.EchoNo) ON tblFunds.FundNo = Sheet1.Fund) ON tblProjects.ProjectNo = Sheet1.Project) INNER JOIN tblSubClass ON Sheet1.[Sub Class] = tblSubClass.SubClassNo) INNER JOIN tblGrantFunds ON tblFunds.FundID = tblGrantFunds.FundID;
May 18 '09 #15
MNNovice
418 Contributor
Denburt:

any field that has all numeric numbers in a field in Excel will need to have that formatted specifically to text if indeed the database has it stored as text for the corresponding table,
1. Are you referring to the fields in the Excel file? For example, Account (in Excel file) need to be changed to be formatted as text and NOT number?
2.
once the format is changed you may need to manually re-input the data (I did)
Manually re-input which data and where? All data in the Excel file?

I am wondering if it would be lot simpler for the end user to re-input data using sfrmPayroll on fromEchoEnter.

Thanks.
May 18 '09 #16
Denburt
1,356 Recognized Expert Top Contributor
@MNNovice
Yes MS Access looks at the Excel file and any fields that appear to be numbers get designated as such even though their related part in MS Access is a text field hence the errors. So if a related field in MS Access is designated as text you should format the related field in Excel as text.

I merely had several records in an Excel file for testing once I changed the formats for several Excel fields I had to re input those few records for the change to take effect. When you get your data as you say you do on a regular basis it may or may not be an issue, we can always deal with on a later basis.
May 18 '09 #17
Denburt
1,356 Recognized Expert Top Contributor
ok I took a look at your Excel file and ran a few more tests and this is what I have found. In Excel have you seen the green box in the top left of a cell that tells you this number is stored as text (look at your sheet then highlight a field that has a number hit f2 then enter it should show up)? Well as long as I see that in the Excel file then MS access has no problem treating this as a text field however when I don't see that then MS Access treats it as a number. once I made that adjustment it worked quite well. When they do a data dump I am not sure how it will handle this so that is what you need to look for and it should be easy to create a macro in Excel to handle this if it is needed. The only other issue I see is if they decide to add an EchoNo or another item from one of your foreign tables then you will not update those records until it is added in the appropriate table such as EchoID. If you are not sure how MS Access is treating your Linked table you can view it in design view and see if the fields you need are being treated as text or number. I hope this helps.
May 19 '09 #18
NeoPa
32,557 Recognized Expert Moderator MVP
It is a very common problem when dealing with record type data in Excel (Importing / exporting etc) that the type of the numeric data (not the format, but the type the data is stored as) causes problems that are not obvious to spot.

This is so common it probably accounts for more than half of the problems I ever see in Excel.

To convert from one type to the other put a formula in one column to produce the results you want, then copy this column. Use Edit / Paste Special / Values over the original column to adjust the data permanently. The new column is no longer required after this point.
May 20 '09 #19
NeoPa
32,557 Recognized Expert Moderator MVP
To convert from string to numeric is simple enough.
Expand|Select|Wrap|Line Numbers
  1. =Val(A1)
To convert the other way is less so. A simple conversion is :
Expand|Select|Wrap|Line Numbers
  1. =Text(A1,"General")
A more common requirement though, is to require the string equivalent to be at least X number of characters. If we take X=6 then this is often done as :
Expand|Select|Wrap|Line Numbers
  1. =Text(A1,"000000")
PS. I should add that to get the formula into the whole column simply copy the top cell and, after selecting all cells in the range, paste it back in.
May 20 '09 #20
Denburt
1,356 Recognized Expert Top Contributor
Thanks for the tidbits NeoPa, those things are good to know. I don't usually do to much in Excel or I try not to :) But I find myself clunking around in it from time to time. Usually sorting out or cleaning up formulas and such that others have written which can be very intersting at times.
May 20 '09 #21
MNNovice
418 Contributor
Denburt / NeoPa

All day yesterday I struggled through this issue so much so that I got totally frustrated and decided not to pursue at this time.

As an alternate option, I chose to simply key in the payroll data. To my pleasant surprise it was not that big. However, I would like to learn the other way where I don't have to type in this info. May be when I have more time to deal with it.

I kept these notes in a file and shall look it over and give it another try at a later date. Many thanks for your help. Please see my other posting on "combining reports".

Thanks & regards.
May 20 '09 #22
NeoPa
32,557 Recognized Expert Moderator MVP
You're more than welcome Den.

I play there quite a lot, and also have a few users who often get stuck on that particular problem.
May 20 '09 #23
NeoPa
32,557 Recognized Expert Moderator MVP
@MNNovice
I'd be happy to go there if you provide a link.
May 20 '09 #24
MNNovice
418 Contributor
NeoPa:

Here is the link to that posting. Thanks.

http://bytes.com/topic/access/answer...ombine-reports
May 21 '09 #25

Sign in to post your reply or Sign up for a free account.

Similar topics

5
3290
by: Scott Tilton | last post by:
I am having a terrible time getting this to work. I am hoping someone out there can help me with very specific code examples. I am trying to get the linked tables in my Access 97 database to be...
2
15481
by: Fred | last post by:
Hi. How do I import while mapping an excel table to an access table please??? I've searched around and all I can find is a software product or code that does the same thing as the access...
4
13451
by: Martin | last post by:
There is an Access table on the network. 15 users who do not have Access are connected to the network. Is there a way for each user to be able to enter one or more rows containing 3 or 4 columns to...
7
10732
by: Bonnie R | last post by:
Hello! I am writing VBA code in Access 97 to import an Excel 2000 Spreadsheet. I had hoped to do this using ODBC, but that was not to be, for who knows what reason. The problem is that I import...
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...
6
6341
by: syvman | last post by:
Hi everyone... I am pulling my hair out trying to do this, and was wondering if someone could give me some assistance... I have an Excel spreadsheet containing several worksheets. I'd like to be...
2
368
by: Arvind R | last post by:
how to ask saveas dialog before writing the data to the excel file? right now im able to save in c drive or any other specified location only. any solution will be a great help! ...
21
6184
by: bobh | last post by:
Hi All, In Access97 I have a table that's greater than 65k records and I'm looking for a VBA way to export the records to Excel. Anyone have vba code to export from access to excel and have the...
7
4057
by: Lisa | last post by:
I have an Access 2000 application that uses the following function to re-link my tables when I switch from my Current back end to a Dummy back end. I also use it to refresh my links. Function...
0
767
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...
0
7114
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
7321
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,...
0
7377
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...
0
7488
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
5623
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,...
1
5045
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
4702
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...
0
3191
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...
0
412
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.