|
-
Aug 13th, 2000, 09:46 AM
#1
Thread Starter
Lively Member
I have a button on a form that does a db backup to the A drive. If there is no disk in the drive I get an error 3043, "Disk or network error" which I trap for and display a msgbox. For some reason after the message box is displayed and the user clicks OK you can no longer do a backup. It is almost like the button click does not run the sub routine anymore. You have to close the app and re-open it and click it again. Anyone seen this before...? If so how can I fix it. How can I make the button run the backup routine again after erroring out once?
-
Aug 13th, 2000, 10:02 AM
#2
Monday Morning Lunatic
Put breakpoints into your button click event, to see what's happening.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 13th, 2000, 10:11 AM
#3
Thread Starter
Lively Member
Here is the code:
Private Sub cmdBckNow_Click()
Set wrkDefault = DBEngine.Workspaces(0)
On Error GoTo err_handle
If InStr(1, txtMedia.Text, ".mdb", vbTextCompare) = 0 Then
MsgBox "Error"
Else
db.Close
DBEngine.CompactDatabase RetAppPath, txtMedia.Text
Call frmMain.Initialize
Call frmMain.Gath_Comp
Call frmMain.Fill_Comp
End If
err_handle:
If Err.Number = 3043 Then
MsgBox Err.Description, vbInformation, "Error"
Exit Sub
End If
End Sub
I figured if I did an Exit Sub in the err_handle that it would exit the sub and then when the button was clicked again it would re-enter and run the code. This is not the case. Cannot figure it out....
-
Aug 13th, 2000, 10:16 AM
#4
Monday Morning Lunatic
Try this:
Code:
Private Sub cmdBckNow_Click()
On Error GoTo err_handle
Set wrkDefault = DBEngine.Workspaces(0)
If InStr(1, txtMedia.Text, ".mdb", vbTextCompare) = 0 Then
MsgBox "Error"
Else
db.Close
DBEngine.CompactDatabase RetAppPath, txtMedia.Text
Call frmMain.Initialize
Call frmMain.Gath_Comp
Call frmMain.Fill_Comp
End If
Exit Sub
err_handle:
If Err.Number = 3043 Then
MsgBox Err.Description, vbInformation, "Error"
Exit Sub
End If
End Sub
I added an Exit Sub just before the error handler code. It's a long shot, but is often a good idea to do anyway. Is there something in your frmMain.Initialize, etc. functions that might disable it somehow?
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 13th, 2000, 10:28 AM
#5
Thread Starter
Lively Member
That still does not do it. The frmMain.Initialize function just re-opens the database connection after doing the backup, does not disable anything. After the code receives the 3043 error it goes directly to the err_handle and does not make it to the frmMain.Initialize function. You would think that after the err message is displayed it would hit the exit sub and bail out so that when you came back to click it again it would re-run, wierd.
-
Aug 13th, 2000, 10:32 AM
#6
Monday Morning Lunatic
To tell you the truth, I've never seen this happen before. A possibility is that VB's error handling is going nuts, and always bypassing the function . Does it display "Error" or anything like that afterwards, or does it just stay silent?
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 13th, 2000, 10:33 AM
#7
Thread Starter
Lively Member
Heres the other strange thing. I have two completely seperate forms that run a database backup. If I encounter the 3043 on one form the database backup will not work anyplace else within the program from any other form until I close the app and re-open it.
-
Aug 13th, 2000, 10:35 AM
#8
Thread Starter
Lively Member
It displays the err_handle message box and then stays silent. Everytime you click the backup db button after the error it does nothing, no error message, no app crash, nothing.
-
Aug 13th, 2000, 10:42 AM
#9
Fanatic Member
Try a breakpoint in the commandbutton click event. When you click after the error, does it break?
GWDASH
[b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]
-
Aug 13th, 2000, 10:47 AM
#10
Thread Starter
Lively Member
I put the breakpoint here:
Sub cmdBckNow_Click()
It breaks when I first click the button, I hit run again, it errors out, I click the button again and it breaks. Is this what you wanted to know?
-
Aug 13th, 2000, 10:50 AM
#11
Monday Morning Lunatic
Yes. We now know that it is opening the event. From this breakpoint, single-step through it to find out where it's going strange.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 13th, 2000, 11:00 AM
#12
Thread Starter
Lively Member
I figured it out. Never did the debugging stuff before, very helpfull! The problem was I close the DB just before I do the backup, it runs the msgbox but does not open the db again so it is closed. It had something to do with that. So I open the db again just after I display the err message and now it works! Thank you very much for your help.....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|