473,320 Members | 2,054 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 4410
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: fish | last post by:
Hi, I have an HTML page with a FORM and some input fields. On the fields I wish to do validation as the punters change the field values. If they get it wrong, then I tell them and then wish...
72
by: Stephen Poley | last post by:
I have quite often (as have probably many of you) come across HTML forms with irritating bits of Javascript attached. The last straw on this particular camel's back was a large form I was asked to...
2
by: Andy Goldstein | last post by:
I have a table where all the TRs have an onClick handler registered. One (and only one) of the rows has 2 text input boxes, where each textbox has an onChange handler registered. Both the onClick...
2
by: lmeng | last post by:
Hi, I am new to this Forum. Thanks in advance for any kind help. In the following HTML code, when I change the value of one text field then click "Modify" button, if the validation fails a...
2
by: Sean | last post by:
Greetings all, I am attempting to make a form that will filter through several tables that (I believe) have refretial integrity. I am pulling data from several tables into the form and i would...
6
by: varkey.mathew | last post by:
Hi there, I have a basic form with a postback. The following is a line of dynamic code written so that when the user clicks on the Button control, he will receive a confirm messagebox. ...
3
by: davidjcampos | last post by:
I'm a definite newbie to javascript, but I have put together some workable code from several different examples on the web. I am using both "onchange" event handlers as well as an "onsubmit" event...
2
by: Martin | last post by:
I am writing a javascript object and once complete i will create an instance of the object to use in my webpage. Within the object constructor i create a form with a select list in it, the form...
13
by: DDragon | last post by:
ok here is the problem, i have to forms which have values i wish to be added together i can add together the values in one form all right but im having problems with adding the values of the other...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.