Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 188
Default Error opening recordset where table is empty (but has field names) - How do I avoid?


Hi All,

This is a supplementary question to my other plea for assistance:

http://groups.google.co.nz/group/mic...db175249696512

OR

http://tinyurl.com/a9vhr



As a workaround for that issue, I have created an MDB file with linked
tables to the FoxPro DB.

I am then pulling the data from access into excel using
ADODB.Recordset objects.

My code works fine (albeit extremely slowly) but falls over on this
line:

rs.Open TableList(Count), cn, adOpenKeyset, _
adLockOptimistic, adCmdTable

for the table that has field names but not actual records.

I have tried surrounding that line with an error trap thus:

On Error GoTo NextTable

rs.Open TableList(Count), cn, adOpenKeyset, _
adLockOptimistic, adCmdTable

On Error GoTo 0

However, it still stops there with an ODBC error.

Is there any way to check for an empty table that won't generate an
error and cause the code to abort?


Thanks,

Alan.

--
The views expressed are my own, and not those of my employer or anyone
else associated with me.

My current valid email address is:



This is valid as is. It is not munged, or altered at all.

It will be valid for AT LEAST one month from the date of this post.

If you are trying to contact me after that time,
it MAY still be valid, but may also have been
deactivated due to spam. If so, and you want
to contact me by email, try searching for a
more recent post by me to find my current
email address



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Error opening recordset where table is empty (but has field names)

how about checking first with
SELECT COUNT(8) FROM TABLENAME
?
If this returns 0 then skip the enext bit.

Or set the recordset to read the data then check it recordcount property

"Alan" wrote:


Hi All,

This is a supplementary question to my other plea for assistance:

http://groups.google.co.nz/group/mic...db175249696512

OR

http://tinyurl.com/a9vhr



As a workaround for that issue, I have created an MDB file with linked
tables to the FoxPro DB.

I am then pulling the data from access into excel using
ADODB.Recordset objects.

My code works fine (albeit extremely slowly) but falls over on this
line:

rs.Open TableList(Count), cn, adOpenKeyset, _
adLockOptimistic, adCmdTable

for the table that has field names but not actual records.

I have tried surrounding that line with an error trap thus:

On Error GoTo NextTable

rs.Open TableList(Count), cn, adOpenKeyset, _
adLockOptimistic, adCmdTable

On Error GoTo 0

However, it still stops there with an ODBC error.

Is there any way to check for an empty table that won't generate an
error and cause the code to abort?


Thanks,

Alan.

--
The views expressed are my own, and not those of my employer or anyone
else associated with me.

My current valid email address is:



This is valid as is. It is not munged, or altered at all.

It will be valid for AT LEAST one month from the date of this post.

If you are trying to contact me after that time,
it MAY still be valid, but may also have been
deactivated due to spam. If so, and you want
to contact me by email, try searching for a
more recent post by me to find my current
email address




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to avoid opening an empty workbook every time I open a file? Nick Papadakis Setting up and Configuration of Excel 2 February 12th 06 11:55 AM
Error when opening recordset of SQL Server via ADO Glenn Ray[_3_] Excel Programming 0 September 2nd 05 11:00 PM
ADO cloned recordset doesn't return field names quartz[_2_] Excel Programming 3 March 16th 05 09:49 PM
Deleting empty rows and field names in report Pele[_2_] Excel Programming 0 November 2nd 04 09:19 PM
DAO query/recordset returns with field names Seth[_4_] Excel Programming 0 August 18th 03 08:36 PM


All times are GMT +1. The time now is 11:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"