Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / November 2007

Tip: Looking for answers? Try searching our database.

Resume Without Error Message

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DoveArrow - 08 Nov 2007 23:59 GMT
I'm trying to run the following event, but whenever I have a location
that has active advisors, in addition to running the delete query that
I want it to run, I get an error message that says "Resume Without
Error." What's going on?

Private Sub Inactive_AfterUpdate()
Dim db As Database
Dim rs As Recordset
Dim str As String

Set db = CurrentDb
Set rs = db.OpenRecordset("jtblLocationAdvisor", dbOpenDynaset,
dbSeeChanges)

On Error GoTo Err_Inactive_Click

If Me.Inactive = True Then
   rs.MoveFirst
   Do Until rs.EOF
       If rs![Location ID] = Forms![frmLocationAdvisors]![Location
ID] Then
           GoTo Duplicate_Inactive_Click
       Else
           rs.MoveNext
       End If
   Loop
End If

Exit_Inactive_Click:
Set db = Nothing
Set rs = Nothing
Exit Sub

Err_Inactive_Click:
MsgBox Err.Description
Resume Exit_Inactive_Click

Duplicate_Inactive_Click:
Select Case MsgBox("There are active advisors listed for this
location. If you wish to delete these advisors from this location,
click OK to continue.", vbOKCancel)
   Case vbOK
       DoCmd.OpenQuery "qdelLocationAdvisors"
       Me.subfrmLocationAdvisors.Requery
   Case vbCancel
       Me.Inactive = False
End Select
Resume Exit_Inactive_Click

End Sub
Bob Quintal - 09 Nov 2007 01:28 GMT
> I'm trying to run the following event, but whenever I have a
> location that has active advisors, in addition to running the
> delete query that I want it to run, I get an error message that
> says "Resume Without Error." What's going on?

Your code is NOT an event, it's a stew of two different events.
Your error handler ends with Resume Exit_Inactive_Click
but you have a label and what should be a separate sub or inline
statement block which ends with another Resume Exit_Inactive_Click
Change that second resume to Goto Exit_Inactive_Click.

> Private Sub Inactive_AfterUpdate()
> Dim db As Database
[quoted text clipped - 42 lines]
>
> End Sub

Signature

Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Dirk Goldgar - 09 Nov 2007 02:27 GMT
> I'm trying to run the following event, but whenever I have a location
> that has active advisors, in addition to running the delete query that
[quoted text clipped - 46 lines]
>
> End Sub

You're using a GoTo statement to transfer control to the code block at
Duplicate_Inactive_Click.  Then that block of code attempts to transfer
control back to Exit_Inactive_Click by using a Resume statement.  But
the Resume statement is only valid when used in an error-handling
procedure;  that is, only if it is reached as the result of an error
having been raised.

You could solve this problem in an ugly fashion by just replacing that
Resume statement with a GoTo statement, but I'd recommend that you
restructure your code to get rid of the GoTo statements entirely.
Incidentally, it would be a good idea to explicitly close your
recordset.

I could be wrong, but it looks to me like code along the following lines
would accomplish what you're trying to do more efficiently:

'----- start of code -----
Private Sub Inactive_AfterUpdate()

   Dim rs As Recordset
   Dim str As String

   On Error GoTo Err_Inactive_Click

   If Me.Inactive = True Then

       Set rs = CurrentDb.OpenRecordset( _
           "SELECT * FROM jtblLocationAdvisor " & _
               "WHERE [Location ID] = " & _
                   Forms![frmLocationAdvisors]![Location ID], _
           dbOpenSnapshot, dbSeeChanges)

       If Not rs.EOF Then
           Select Case MsgBox( _
                       "There are active advisors listed for this " & _
                           "location. If you wish to delete these " & _
                           "advisors from this location, click OK "& _
                           "to continue.", _
                       vbOKCancel, _
                       "Active Advisors Found")
               Case vbOK
                   DoCmd.OpenQuery "qdelLocationAdvisors"
                   Me.subfrmLocationAdvisors.Requery
           Case vbCancel
               Me.Inactive = False
           End Select
       End If

       rs.Close

   End If

Exit_Inactive_Click:
   Set rs = Nothing
   Exit Sub

Err_Inactive_Click:
   MsgBox Err.Description
   Resume Exit_Inactive_Click

End Sub
'----- end of code -----

Note: the above code assumes that [Location ID] is numeric.  If it's
text, the constructed SQL statement must be modified to enclose the
value in quotes.

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

DoveArrow - 14 Nov 2007 18:57 GMT
> Innews:1194566386.009862.20520@z24g2000prh.googlegroups.com,
>
[quoted text clipped - 122 lines]
>
> - Show quoted text -

Your solution worked beautifully Dirk. Thank you.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.