By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,988 Members | 1,049 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,988 IT Pros & Developers. It's quick & easy.

filtering form onchange event

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a

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

P: n/a
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

P: n/a
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.