Union query

coucar3456

New Member
Joined
Jun 29, 2016
Messages
11
Group,

I have a macro set up to pull a total of 10 files from a folder on my desktop. Then I have a union query to merge all 10 tables. The union query works fine, however, some weeks I may not have 10 files, it may be 6 to 8 files. Because the union query is already staged to merge 10 files it will error out if there is not 10 files. Is there a way to keep the union query set on merging 10 tables and on error ignore.

Carter
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
one way, is just before the merge is initiated to use
On Error Resume Next
Its not always the best way of error trapping if you need to do specific events, but it might be your fix
 
Upvote 0
I don't think that applies to SQL statements (at best the error means the query didn't work so back to square one).
 
Upvote 0
I have my import macro set to On ERROR GO TO NEXT. If I can get the union query to do the same thing I think it will work.
I can edit the SQL by removing the union statement for the tables that didn't import and the query work just fine.
 
Upvote 0
MSAccess does not have ON ERROR GOTO NEXT in the SQL language for queries.

Perhaps you post your sql and/or code to show what you are doing now.
 
Upvote 0
My mistake, I see a question and don't look at the forum its in
 
Upvote 0
My mistake, I see a question and don't look at the forum its in
Tsk! Tsk! Looks like its to the time-out corner for you!
;)
 
Upvote 0
Do the files have specific names that do not change?
If yes you could write some VBA to edit the SQL statement.
Can you paste the SQL statement then I can give you a more conclusive answer.

Jack
 
Upvote 0

Forum statistics

Threads
1,221,813
Messages
6,162,126
Members
451,743
Latest member
matt3388

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top