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

Can I force an append query in VBA?

2
I would like to know if I can force an append query in Access VBA to continue if it encounters a field in the source table that does not exist in the target table and just ignore that field.

My dilemma is that I am trying to import over 900 tables that were downloaded from the internet. They represent data from multiple schedules over multiple quarters. For example:
Schedule A 03-31-10
Schedule A 12-31-09
.
.
Schedule A 03-31-04
Schedule B 03-31-10
Schedule B 12-31-09
.
.
Schedule B 03-31-04

Since the source schedules have changed numerous times over the past five years and will likely continue to change in the future, there are fields in older tables that do not exist in newer tables and vice versa.

I am really only interested in fields that are present in the newest tables. So, I wrote some code to loop through each file starting with the newest ones and import them to Access. For the newest files, Access makes a table that contains each field from the new files. Subsequent imports append to these tables. That works great except that when Access gets to a field in an older file that does not exist in the target table, it throws a terminal error saying the field does not exist.

The reason I can not just use a SELECT statement that spells out each field from the newest tables is that six months down the road, there may be a new field added that I want. And, I want to avoid having to edit the SELECT statement each time a new field is added because there are about 40 different schedules.

My ideal solution would be to tell Access to "import the table and if you get to a field that does not exist in the target table, just ignore it and keep going". Wishful thinking?

I would appreciate your thoughts on this!
Jun 22 '10 #1

✓ answered by vb5prgrmr

Okay, so you are using the Open Statement to open these files and read them in with the Line Input Function? If so, you should be able to know how many fields there are and if you know that, you should be able to do an alter table statement to add a field if needed...



Good Luck

2 1394
vb5prgrmr
305 Expert 100+
Okay, so you are using the Open Statement to open these files and read them in with the Line Input Function? If so, you should be able to know how many fields there are and if you know that, you should be able to do an alter table statement to add a field if needed...



Good Luck
Jun 23 '10 #2
bmac
2
@vb5prgrmr
vb5prgrmr,
I am actually just importing them at this point. After the first import of Schedule A which creates a table, each subsequent import of Schedule A files appends to the new table. That is where the problem has been.

But, your answer was definitely right on! What I decided to do was add the fields in code following the first import. There aren't too many so it seems to be working perfectly.

Thank you for the input!
Jun 24 '10 #3

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

Similar topics

2
by: John | last post by:
Hi - I am trying to perform a simple append query, with no luck. I have a table (MktPrices) that has the following fields: BondID, PriceDate, Price. The objective is to allow the user to input a...
2
by: JMCN | last post by:
hi i need some advice on whether if it would be better to use an append query or an update query. here is the situation, i have linked another database table to my current database. then i...
2
by: JMCN | last post by:
hi i have a general question regarding append queries in access 97. each week i need to update my table(tblonlinereg) with new or modified records. firstly, i import the text file into my...
2
by: Paul Wagstaff | last post by:
Hi there I have 2 tables: tblAccuracy & tblClearance Users add new records to tblAccuracy using frmRegister. Under specific conditions I need to append the current record from frmRegister into...
1
by: David Barger | last post by:
Greetings, It appears that an Append Query I run in Access XP is randomly failing to append a field. I have payroll data being entered into a payroll database. This data is exported daily to...
2
by: Ray Holtz | last post by:
I have a form that shows a single record based on a query criteria. When I click a button it is set to use an append query to copy that record to a separate table, then deletes the record from the...
4
by: robboll | last post by:
When I try to use an append query from an oracle link it takes forever. I am exploring the idea of doing an append action using a pass-through query. If I have an Oracle ODBC connection to...
4
by: pmacdiddie | last post by:
I have an append query that needs to run every time a line item is added to a subform. The append writes to a table that is the source for a pull down box. Problem is that it takes 5 seconds to...
1
by: hr833 | last post by:
hi.. i'm using a append query to filter some new records that must be updated in the lookup table. In this lookup table it consist of the part number and the type of the product. the part number...
4
by: Scott12345 | last post by:
Hi, here is my situation, I have a DB that tracks machine downtime (30 machines) per day. Several users will update this through the day. I created an append query that creates 30 dummy values and...
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...
0
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...
0
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
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
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...
1
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...
0
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,...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.