ADO Conn to csv - error trapping suggestion?

ClimoC

Well-known Member
Joined
Aug 21, 2009
Messages
584
How would you do this?

Code:
strsql1 = "SELECT * From " & fName
StatsForm.TextBox1.Value = StatsForm.TextBox1.Value & "     querying " & fName & "..."
DoEvents
On Error GoTo oops
Err.Clear
    If Not FPRSet Is Nothing Then Set FPRSet = Nothing
    With cnImportConn1
                    .ConnectionTimeout = 2
                    .CursorLocation = adUseClient
                    .Open strConn1
                    .CommandTimeout = 0
                    Set FPRSet = .Execute(strsql1)
    End With

Basically, if the user using the workbook either doesn't have access to the drive/path where the CSVs are, or the CSV isn't there, it will bug 'not a valid path...file' or whatever.

I'm thinking of using a FileSystemObject.GetFolder method to a variant, and if the variant isn't empty, then proceed with establishing csv connection, otherwise quit/go to next?

Anyone got a better idea? (Preferably one that's a single line? :))

C
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Forum statistics

Threads
1,215,381
Messages
6,124,614
Members
449,175
Latest member
Anniewonder

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