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

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?
RobertStammAsked:
Who is Participating?
 
Gal_ateaConnect With a Mentor Commented:
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
0
 
Jokra_the_BarbarianCommented:
You could handle the error and keep going:

On Error GoTo ErrorHandler
...
...
..

Exit_Here:
     Exit Sub

ErrorHandler:
       Select Case Err.Number
             Case 2771
                   Resume Next
             Case Else
                    MsgBox "Error number: " & Err.Number & " - " & Err.Description
       End Select
Resume Exit_Here
                     
0
 
Gal_ateaCommented:
Hi Robert,
Are you trying to use the filter to limit the data displayed in your form?
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
RobertStammAuthor Commented:
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.
0
 
shanesuebsahakarnCommented:
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.
0
 
RobertStammAuthor Commented:
These comments and suggestions look good.  I'll try them and award points later.
0
 
Gal_ateaCommented:
Thanks for the grade Robert, glad I could help!
0
All Courses

From novice to tech pro — start learning today.