?
Solved

Can someone help me with this code?

Posted on 2003-02-19
2
Medium Priority
?
271 Views
Last Modified: 2010-08-05
I have a form that I use the filter by form command with, and when the filter is applied and it doesn't find any records to be filtered, it gives me a message for Run time error 3021. Then it asks me if I want to debug or end, you know....

Well here is the code.

Private Sub Form_Current()
   
    If Me.NewRecord Then
       Me.RecordsetClone.MoveLast
       Nav2 = Me.RecordsetClone.AbsolutePosition + 1
    Else
        Me.RecordsetClone.Bookmark = Me.Bookmark
        Nav = Me.RecordsetClone.AbsolutePosition + 1
    End If
   
    If Me.CurrentRecord Then
        Me.RecordsetClone.MoveLast
        Nav2 = Me.RecordsetClone.AbsolutePosition + 1
    Else
        Me.RecordsetClone.Bookmark = Me.Bookmark
        Nav = Me.RecordsetClone.AbsolutePosition + 1
    End If
   
    If Me.FilterOn = True Then
        Me.Label148.Visible = True
    Else
        Me.Label148.Visible = False
    End If
   
End Sub


Is their any way I can code in a message box to pop up if their is no records that match the filter.
0
Comment
Question by:Mtlca401
[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
2 Comments
 
LVL 8

Accepted Solution

by:
dds110 earned 100 total points
ID: 7983446
Private Sub Form_Current()
On Error GoTo Err_Form_Current:  
   If Me.NewRecord Then
      Me.RecordsetClone.MoveLast
      Nav2 = Me.RecordsetClone.AbsolutePosition + 1
   Else
       Me.RecordsetClone.Bookmark = Me.Bookmark
       Nav = Me.RecordsetClone.AbsolutePosition + 1
   End If
   
   If Me.CurrentRecord Then
       Me.RecordsetClone.MoveLast
       Nav2 = Me.RecordsetClone.AbsolutePosition + 1
   Else
       Me.RecordsetClone.Bookmark = Me.Bookmark
       Nav = Me.RecordsetClone.AbsolutePosition + 1
   End If
   
   If Me.FilterOn = True Then
       Me.Label148.Visible = True
   Else
       Me.Label148.Visible = False
   End If
   
Exit_Form_Current:
    Exit Sub

Err_Form_Current:
If Err.Number = 3021 Then
'There was no record found
    MsgBox "No Record Found"
    Resume Exit_Form_Current:
Else
    MsgBox Err.Description,,Err.Number
    Resume Exit_Form_Current:
End If

End Sub


HTH
0
 

Author Comment

by:Mtlca401
ID: 8010773
Thank you for the answer, even though I figured it out I'll still accept your answer so you can get points for it!
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
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 Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

752 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