[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

checking the open state of a text file opened as a database

Posted on 2003-11-15
6
Medium Priority
?
273 Views
Last Modified: 2010-05-01
I am using the code below to open a csv file as a database and read records from it. Works great. The problem is, when the routine that reads the records (some 179,000 of them) is canceled the database needs to be closed, but some times, it doesn't get opened before the cancel is submitted, so when it hits the end of the sub routine it tries to close the db as normally, it would be open when the sub is done.  How can I test the open state of this?  you'd think that rs.state would work but it "isn't available".

Dim db As Database, rs As Recordset
Set db = OpenDatabase("X:\Zion\zms\ZMS_XCART_MAINT\", False, _
False, "TEXT;Database=X:\Zion\zms\ZMS_XCART_MAINT\;table=PRODMAST.TXT")
Set rs = db.OpenRecordset("PRODMAST.TXT")
0
Comment
Question by:digitalwav
  • 2
  • 2
  • 2
6 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 9756971
Please maintain your open questions:

1 06/03/2003 250 Html Hyperlinks in IE 6 SP1 under W2k - ...  Open Browsers Issues
2 06/21/2003 125 Segmentation fault starting apache 2.0.4...  Open Apache
3 10/14/2003 250 Stopping NT Logon Scripts from Running W...  Open Windows 2000
4 07/20/2003 125 Full rights on locally mounted VFAT part...  Open Linux Administration

Thanks,
Anthony
0
 
LVL 3

Accepted Solution

by:
NBrownoh earned 1000 total points
ID: 9757091
why dont you just use some error handling, generically you could just to this:

On Error Resume Next

but that will ignore all errors, so for a very direct result you could do this:

On Error Goto ErrHand

'Your Code Here
Exit Sub
ErrHand: If err.number = ThatErrorNum then
                       exit sub
              else
                       msgbox "An error has occured"
              end if

'----

replace ThatErrorNum with the error number generated for your question.  If the err.number prop matches the error number that you want to ignore it will simply exit the routine without ending your program, if the number doesnt match it will tell you something went wrong and exit the routine.  You could use the Err.Number and Err.Description properties to notify the user of the error that occured.
0
 
LVL 1

Author Comment

by:digitalwav
ID: 9758686
Dear Anthony, with all due respect, if you had read any of the questions you want me to "maintain" you'd notice that three out of the four are marked for deletion. I can't really do much after that. They're pending deletion.

If you have problems with how I manage the very few open questions I have please contact me directly. This is terribly off topic and very annoying.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Author Comment

by:digitalwav
ID: 9758688
NBrownoh- I guess I'm going to have to! I can't find any other way around it.

Thanks for your help!
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 9758780
>>I can't really do much after that. They're pending deletion.<<
Yes you can.  You can post a message in Community Support to remind them to close these two open questions (the have evidently fallen through the cracks):
http://www.experts-exchange.com/Web/Browser_Issues/Q_20635053.html
http://www.experts-exchange.com/Web/Web_Servers/Apache/Q_20655720.html
Let me know if you need help with that.

That leaves this open question from last July:
http://www.experts-exchange.com/Operating_Systems/Linux/Linux_Administration/Q_20684204.html

Your questions are your responsibility and your will find experts more responsive, if you leep up with them.

Thanks,
Anthony
0
 
LVL 3

Expert Comment

by:NBrownoh
ID: 9759586
ok cool, its really not a bad practice.  You should use error handling in every routine in your code since any stupid little error can cripple your program and cause it to terminate, using error handling might notify the user of a problem but it lets them keep running the program.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month19 days, 6 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question