Solved

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

Posted on 2003-11-15
6
266 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

839 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