469,579 Members | 1,830 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,579 developers. It's quick & easy.

filtering form onchange event

I am having difficulty filtering a form as the user types in a onchange
event

here is my code

strFilter = cboCriteria.Value & " LIKE '" & Me!txtCriteria.text
& "*" & "'"
If Len(strFilter ) 0 Then
Me.FilterOn = True
Me.Filter = strFilter

Me!txtCriteria.SelStart = Len(Me!txtCriteria.text)
' End If

My problem occurs when the filter produces no results
The line
Me!txtCriteria.SelStart = Len(Me!txtCriteria.text)
gives me an error in the likes of: Cannot reference a control which
does not have the focus

can anybody help me
thanks

Aug 4 '06 #1
4 4124
Dave wrote:
I am having difficulty filtering a form as the user types in a onchange
event

here is my code

strFilter = cboCriteria.Value & " LIKE '" & Me!txtCriteria.text
& "*" & "'"
If Len(strFilter ) 0 Then
Me.FilterOn = True
Me.Filter = strFilter

Me!txtCriteria.SelStart = Len(Me!txtCriteria.text)
' End If

My problem occurs when the filter produces no results
The line
Me!txtCriteria.SelStart = Len(Me!txtCriteria.text)
gives me an error in the likes of: Cannot reference a control which
does not have the focus

can anybody help me
thanks
Maybe something like
If Me.Recordsetclone.Recordcount 0 then
Me!txtCriteria.SelStart = Len(Me!txtCriteria.text)
Endif
Aug 4 '06 #2

salad wrote:
Maybe something like
If Me.Recordsetclone.Recordcount 0 then
Me!txtCriteria.SelStart = Len(Me!txtCriteria.text)
Endif

The problem if there are no records then I don't have the cursor at the
end of the textbox
So the user justs overwrites whatever was in the textbox

Aug 4 '06 #3
Dave wrote:
salad wrote:
>>Maybe something like
If Me.Recordsetclone.Recordcount 0 then
Me!txtCriteria.SelStart = Len(Me!txtCriteria.text)
Endif

The problem if there are no records then I don't have the cursor at the
end of the textbox
So the user justs overwrites whatever was in the textbox
I guess I'd need to see the form. I figured if there were no records
returned after filtering, you wouldn't want to tell it where SelStart
is. I really don't know what you want to accomplish if nothing is
returned. Perhaps you can change the value of what is typed in
txtcriteria by one char less.

Aug 4 '06 #4
The form is basically a list of record with a search with criterias at
the top

As the user types the characters of what he wants to search is a
textbox, the form is filtered.
If what he writes returns no record, I want him to able to correct what
he has written so that he does see the record that he was searching.

The problem is that if no records are returned from the filter, than I
can't access the properties of the textbox in which he is writing

salad wrote:
Dave wrote:
salad wrote:
>Maybe something like
If Me.Recordsetclone.Recordcount 0 then
Me!txtCriteria.SelStart = Len(Me!txtCriteria.text)
Endif


The problem if there are no records then I don't have the cursor at the
end of the textbox
So the user justs overwrites whatever was in the textbox
I guess I'd need to see the form. I figured if there were no records
returned after filtering, you wouldn't want to tell it where SelStart
is. I really don't know what you want to accomplish if nothing is
returned. Perhaps you can change the value of what is typed in
txtcriteria by one char less.
Aug 7 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by fish | last post: by
72 posts views Thread by Stephen Poley | last post: by
2 posts views Thread by Andy Goldstein | last post: by
2 posts views Thread by Sean | last post: by
6 posts views Thread by varkey.mathew | last post: by
3 posts views Thread by davidjcampos | last post: by
2 posts views Thread by Martin | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.