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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run-time error 2467 on my Fuctions 1

Status
Not open for further replies.

Triacona

Technical User
Jun 11, 2009
462
GB
Dear All,

I have a problem that started yesterday.
I have had these functions and they have worked for the last 8-10 months, but yesterday I got the following error, after clicking my Run Report or Run Query Button.
Error 2467 said:
Run-time error '2467' The Expression you entered refers to an object that is closed or doesn't exist
The Functions are:
Code:
[blue]Function[/blue] QueryExists(stDocName [blue]As String[/blue]) [blue]As BooleanOn 

Error Resume Next [/blue]

QueryExists = (CurrentDb.QueryDefs(stDocName).NAME = stDocName)

[blue]End Function[/blue]

[blue]Function[/blue] ReportExists(stDocName [blue]As String[/blue])[blue] As BooleanOn 

Error Resume Next[/blue]

ReportExists = (CurrentProject.AllReports(stDocName).NAME = stDocName)

[blue]End Function[/blue]
It might be a references problem, are there right and wrong references to use in VB?
Please help this is so frustrating[sadeyes]
Thank you [smile]
Just in case the code above bunches when I submit:
[blue]Function[/blue] QueryExists(stDocName [blue]As String[/blue]) [blue]As BooleanOn

Error Resume Next [/blue]

QueryExists = (CurrentDb.QueryDefs(stDocName).NAME = stDocName)

[blue]End Function[/blue]

[blue]Function[/blue] ReportExists(stDocName [blue]As String[/blue])[blue] As BooleanOn

Error Resume Next[/blue]

ReportExists = (CurrentProject.AllReports(stDocName).NAME = stDocName)

[blue]End Function[/blue]


Thank you,

Kind regards

Triacona
 
Dear All,

I have removed a few references and I have now the following error:
Run-time error '3265': said:
Run-time error '3265': Item not found in this collection

Here is a list of my references:
Visual Basic For applications
Microsoft Access 11.0 Object Library
CAPS Functions
Microsoft DAO 3.6 Object Library

Thank you for your forthcoming help [smile]


Thank you,

Kind regards

Triacona
 
most likely your name is incorrect. Assume a query def is "qryOne" and you pass "queryOne". Since the item "queryOne" does not exist in the query def collection you get the error.
 
[!]ON [/!]Error Resume Next

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Dear PHV,

Thanks, but I do have the ON before: error resume next [smile] I just left it out by mistake when I posted, sorry.

@MajP It just keeps giving me an error, saying it is not there, which I know but have code within the button to determine that.

I originaly got the Function code from Tek-Tips.

I use the Functions within my buttons i.e.
That produces a msgbox saying the report does not exist, as below.

This was working for 8-10 months, I don't know if my IT dept changed anything, but they have not found out yet.

I have listed my current references for the project above.

Code:
Private Sub SrRunQuery_Click()
'*SERVICE REQUEST SR RUN QUERY BUTTON**********
On Error GoTo Err_SrRunQuery_Click

    Dim stDocName As String
        stDocName = ListSR.Column(2)

    If Not QueryExists(stDocName) Then
        msgbox stDocName & " query doesn't exist, RUN the REPORT!", vbExclamation, "Run The REPORT!!!"
    ElseIf Not Me.SubFrmInput.Form.txtEndDate.Enabled = True Then
        DoCmd.OpenQuery stDocName, acNormal, acEdit
    ElseIf IsNull(Me.SubFrmInput.Form.txtStartDate And Me.SubFrmInput.Form.txtEndDate) Then
            DoCmd.RunMacro "MsgBoxNoDate"
    Else: DoCmd.OpenQuery stDocName, acNormal, acEdit
            
    End If 'If Not QueryExists(stDocName) Then
    
Exit_SrRunQuery_Click:
    Exit Sub

Err_SrRunQuery_Click:
    msgbox Err.Description
    Resume Exit_SrRunQuery_Click
    
End Sub

Any help you can give would be greatly appreciated![smile]
This is really getting me down, it worked once...[sadeyes]
Thank you again for all your help.


Thank you,

Kind regards

Triacona
 
Which line of code raises the error ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank you all for you wonderful help! [2thumbsup] Great forum!
@Duane:
Thannks that did seem to be the problem, and it works now.
Within VB I clicked:
Options -> General Tab -> I Changed Break on All Errors to Break on Unhandled Errors.

Thanks again for all your help.
Also to note I did not change the above options, but my Citrix profile was going a bit wonky.

My Citrix Profile might have to be reset.

But after changing this it all seemed to work.

Thanks again all - MajP; PHV; and Duane. [bigsmile]
Have a star Duane! [smile]

Thank you,

Kind regards

Triacona
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top