Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

How to close Filter by Form view using code

Posted on 2007-11-26
5
Medium Priority
?
448 Views
Last Modified: 2008-02-01
When you click on the Filter by Form toolbar button, the active form changes to filter-by-form view. If you then click 'Close' on the Filter/Sort toolbar, the form reverts to normal view.
What is the code equivalent of clicking 'Close' on the Filter/Sort toolbar?
I've tried
   DoCmd.RunCommand acCmdClose
but I get
   Error: No current record.
0
Comment
Question by:Milewskp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 20354839
try this:
DoCmd.RunCommand acCmdCloseWindow
0
 
LVL 3

Expert Comment

by:incrediblejohn
ID: 20355623

DoCmd.RunCommand acCmdRemoveFilterSort
0
 
LVL 1

Accepted Solution

by:
Milewskp earned 0 total points
ID: 20451117
DoCmd.RunCommand acCmdCloseWindow results in a "No Current record" error.

DoCmd.RunCommand acCmdRemoveFilterSort results in a "The action RemoveFilterSort is not available now" error.

I found that this works:

Private Sub Form_Error(DataErr As Integer, Response As Integer)
    Dim Answer As String
    Const conCantFilterByFormWhenRecordSourceIsARecordsetError As Integer = 2594 'AccessError constant
    
    If DataErr = conCantFilterByFormWhenRecordSourceIsARecordsetError Then
        'Can't FilterByForm when Me.Recordsource is a Recordset
        Answer = MsgBox("Filter by Form is not allowed for this form." & vbCr & _
        "(Recordsource of the form or subform is a Recordset.)", vbOKCancel + vbExclamation)
        Response = acDataErrContinue 'Prevent Access from displaying its own message.
        DoCmd.Close 'Close FilterByForm view
        DoCmd.OpenForm Me.Parent.Name 'Reopen form.
 
    End If
    
End Sub

Open in new window

0
 
LVL 1

Expert Comment

by:Vee_Mod
ID: 20535819
Closed, 500 points refunded.
Vee_Mod
Community Support Moderator
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

647 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