Solved

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

Posted on 2003-11-15
6
263 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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…
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…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now