Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Application-defined or object-defined error

Status
Not open for further replies.

hwkranger

MIS
Nov 6, 2002
717
US
Having trouble with the following Sub, It's a CLICK (that closes the Form):

I'm recieving the following error: Application-defined or object-defined error

Private Sub Close_Click()
'Balance Branch Form.Close
On Error GoTo Balance_Branch_Form_Close_Err

With CodeContextObject
If (.Error1 = 1) Then
Beep
MsgBox "One of the ""Differences"" is not equal to $0 so you cannot marked this branch balanced. You must fix this branch so all the ""Differences"" are $0 or mark this branch as ""Branch Not in Balance"".", vbExclamation, ""
Exit Sub
End If
If (.Error2 = 1) Then
Beep
MsgBox "You have indicated this branch is not in balance, so you must enter an explanation in the Comments section.", vbOKOnly, ""
SetFocusComments
Exit Sub
End If
If (Eval(&quot;DCount(&quot;&quot;[ID]&quot;&quot;,&quot;&quot;DAILY OUTAGE TICKETS&quot;&quot;,&quot;&quot;[Branch]=[Form].[BRANCH_RECORD] And [RecoveryType]='Unrecovered' And [LtrDate] Is Null&quot;&quot;)<>0 And MsgBox(&quot;&quot;You have Unrecovered letters that have not been printed. Would you like to print these now?&quot;&quot;,4,&quot;&quot;Letter&quot;&quot;)=6&quot;)) Then
DoCmd.OpenReport &quot;Daily Outage Tickets Letter&quot;, acPreview, &quot;&quot;, &quot;[Branch]=[Forms].[Balance Branch].[BRANCH_RECORD] And [RecoveryType]='Unrecovered' And [LtrDate] Is Null&quot;
DoCmd.PrintOut acPrintAll, , , acHigh, 1, True
End If
If (.[Balanced/Research] <> 0) Then
DoCmd.Close acForm, &quot;Balance Branch&quot;
End If
If (.[Balanced/Research] = 0) Then '*** ERROR Happens Right here What's wrong with this line??
'DoCmd.RunMacro &quot;Balance Branch Form.Close2&quot;, , &quot;&quot;
If (Eval(&quot;MsgBox(&quot;&quot;You have not marked this branch as Balanced or Branch Not in Balance. Do you still want to close the form?&quot;&quot;,4,&quot;&quot;Unbalanced Branch&quot;&quot;)=6&quot;)) Then
DoCmd.Close acForm, &quot;Balance Branch&quot;
End If
End If
End With


Balance_Branch_Form_Close_Exit:
Exit Sub

Balance_Branch_Form_Close_Err:
MyErrorHandler (&quot;Form close&quot;)
Resume Next
'Resume Balance_Branch_Form_Close_Exit
End Sub

Randall Vollen
National City Bank Corp.
 
I found my answer...

You can't close the form before the end of your code if you're referencing objects located on the form. makes sense :)

Randall Vollen
National City Bank Corp.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top