Link to home
Start Free TrialLog in
Avatar of richardbc
richardbcFlag for Australia

asked on

Can you trap Too many fields defined error.

I am using DAO in VB6 to open a third party Excel file
I am getting error 3190 "Too many fields defined."
The Excel file contains data but also many unused blank columns.
Is there any way to open tis file without the error?
The current code that gives the error is below
Set WorkingTable = gdbCurrentDB.OpenRecordset(tblObj.Name, dbOpenSnapshot, dbReadOnly)

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of aikimark
aikimark
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of richardbc

ASKER

Thanks for the comments
As I said the file is third party and I am trying to get them to produce the file with less columns but ...............
The file is also odd in that it does not allow you to delete columns - it is not locked but you can highlight one or more columns and then delete them - they vanish for an instant and then reappear!!
So as a workaround I have copied the data only to a new worksheet and saved that - this works but it is not a good solution as it requires outside intervention and it is not transparent to the user.
Is there any way to tell the spreadsheet that there is only say 100 columns?
Is there any way to tell VB to only open X tables?
<<Is there any way to tell the spreadsheet that there is only say 100 columns?>>
The procedure I out lined, which in order to work, the spreadsheet must be unproctected.
<<Is there any way to tell VB to only open X tables?>>
  Not  When you use the built-in stuff.   If you opened it in code and did the import work yourself, then yes you can look at each cell and determine if it is empty.
JimD
@richardbc

Please post this strange Excel file.
This question should be closed with no points refunded.

The answers to this question are:
* yes, you can trap errors with the ON ERROR statement
* DAO requires contiguous columns when opening ODBC sources, such as Excel worksheets.
split points between #23691962 and #23691967
I cannot post the file as it is owned by someone else and none of the answers showed any way to trap the error when opening a third party file and noone answered this
I think answers should answer the question and not just ramble around
Therefore I feel no points should be awarded
@richardbc

"answers should answer the question and not just ramble around"
1. we did answer your two questions (Yes, the error can be trapped.  No, you can not use the Jet engine/DAO on data sources with missing columns)

2. any rambling is just your perception and were probably attempts to find a workaround.

===========
There is a work-around, but you have shut down that solution with your request to close this question.  In the future:
* Think about problems and solutions, rather than questions and answers.  
* The way you phrase your posted question greatly affects the number of respondents and the 'flavor' of their comments.
* If you develop a reputation for poor question quality and a propensity for pre-solution question closing/deleting requests, you will find that VERY FEW of your future questions will even get a response.