Solved

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

Posted on 2003-11-15
6
265 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 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

773 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