Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 07-07-2006, 09:46 AM   #1
johndoomed
VBA idiot
 
Join Date: Nov 2004
Location: KragerÝ, Norway
Posts: 174
Thanks: 0
Thanked 2 Times in 1 Post
johndoomed is an unknown quantity at this point
Problem with search-function (.SelStart - Run-time error 2185)

Hi all!

I have some problems with a search function, or more precise the error-handling of the function.

Iíve added an unbounded textbox (Called search) in the toptext of a continuous form. The form is based on a query which is connected to the unbounded textbox (search).

Iíve written a basic vb function with is activated by the textbox (on change).

Code:
Private Sub search_Change()

    Me.Requery
    
        With Me!search
        Dim toSearch As String
        .SetFocus
        .SelStart = 300
        End With
    
End Sub
This works well, until there are no more posts to show. Then I get:

Quote:
Run-time error Ď2185í Ė You can't reference a property or method for a control unless the control has the focus
The cause is the .SelStart = 300. Without that line, the Run-time error will not occur. But, the line has to stay..

Iíve tried all the Ifís and elseís I know, but could not find a fix. Any ideas?

johndoomed is offline   Reply With Quote
Old 07-10-2006, 08:55 AM   #2
johndoomed
VBA idiot
 
Join Date: Nov 2004
Location: KragerÝ, Norway
Posts: 174
Thanks: 0
Thanked 2 Times in 1 Post
johndoomed is an unknown quantity at this point
Just to work around this problem, how do I make a "if (there-is-no-records) then"?
johndoomed is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
multi field search criteria problem itchy Queries 6 07-26-2007 05:21 AM
Elapsed Time Formated as Y/M/D Problem bhelms General 12 12-12-2005 05:01 PM
Database Update Randomblink Modules & VBA 6 02-16-2004 08:24 AM
code speed depends how many time I run it paulmcdonnell Modules & VBA 3 09-16-2002 09:06 PM
Split Database goaksmith General 4 08-16-2002 07:02 AM




All times are GMT -8. The time now is 10:53 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Sponsored Links

How to advertise

Media Kit


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World