Solved

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

Posted on 2003-11-15
6
268 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 250 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…

690 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