Run -time error '2771': The bound or unbound object frame you tried to edit doesn't contain an OLE object.

Posted on 2004-10-21
Last Modified: 2010-08-05
I have a Access form that has several combobox lookup controls are used to create the SQL statement to apply filters to the querry.  This worked fine if the filter found matching records or not.  My problems started when I attempted to add a activex date control.  The form and code works fine as long as the applied filter finds matching records.  If no matching records are found, and I attempt to change the axtiveX control of my date ranges for the querry filter, I recive the following message.

Run -time error '2771':
The bound or unbound object frame you tried to edit doesn't contain an OLE object.

It breaks on the following code.

If atxStartDate.Value > atxEndDate.Value Then
    atxEndDate.Value = atxStartDate.Value
    txtEndDate = VBA.FormatDateTime(atxEndDate.Value, vbShortDate)
End If

The controls are not bound to the record, they are only used to write the SQL code to apply to the filter of the querry.

Any Ideas?
Question by:RobertStamm
    LVL 11

    Expert Comment

    You could handle the error and keep going:

    On Error GoTo ErrorHandler

         Exit Sub

           Select Case Err.Number
                 Case 2771
                       Resume Next
                 Case Else
                        MsgBox "Error number: " & Err.Number & " - " & Err.Description
           End Select
    Resume Exit_Here
    LVL 4

    Expert Comment

    Hi Robert,
    Are you trying to use the filter to limit the data displayed in your form?

    Author Comment

    Yes, I'm trying to use the filter to limit the records displayed on my form?  I have several comboboxes that create a SQL statement to show matching records in a final combobox. This works fine.  The issue I'm having is when I apply the same information to the form filter.  All works well until send a filter that produces no results.  At that time when I try to expand the date range I recieve the above message.  I could try to ignore the message but I haven't tried that yet.

    PS. I'm a self-taught programmer and some of these issues are new to me.
    LVL 41

    Expert Comment

    You could check to see if the form is currently showing no records:
    If Me.CurrentRecord=0 Then

    This only works though if the form does not allow additions.
    LVL 4

    Accepted Solution

    A friend of mine wrote a form that has similar functions for filtering the form. He checked after setting the filter and if no records were returned popped up a message box to warn the user, then turned the filter off:

    Private Sub CmdUpdateFilter_Click()
        'Re-set filter
        UpdateFilterHM 'Call the function to build the filter
        'If no records match current filter
        If Me.Recordset.EOF = True Then
            NotFound = "No records Found Matching Your Criteria"
            MsgBox (NotFound)
            Me.FilterOn = False
        End If
    End Sub

    Author Comment

    These comments and suggestions look good.  I'll try them and award points later.
    LVL 4

    Expert Comment

    Thanks for the grade Robert, glad I could help!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
    Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
    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…
    In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

    846 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

    3 Experts available now in Live!

    Get 1:1 Help Now