473,416 Members | 1,510 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,416 software developers and data experts.

Combobox Requery Onchange

Gil
Hello,
I want a combox to requery each time it is being changed.

What i am trying to do is have the combo box filter to the text being
entered.
The combo1 rowsource is:
SELECT * FROM tbl WHERE field1 Like combo1 & "*"

The code looks like this:

Private Sub combo1_Change()
Me.combo1.Requery
End Sub

When i do this i get the following error:
"Your must save the current field before you run the requery action."

How can i refresh the rowsource as I am typing in the combo1?
Maybe there is another aproach to this all together...
Thanks for Any help,
Gil

Nov 25 '05 #1
6 8197
Gil wrote:
Hello,
I want a combox to requery each time it is being changed.

What i am trying to do is have the combo box filter to the text being
entered.
The combo1 rowsource is:
SELECT * FROM tbl WHERE field1 Like combo1 & "*"

The code looks like this:

Private Sub combo1_Change()
Me.combo1.Requery
End Sub

When i do this i get the following error:
"Your must save the current field before you run the requery action."

How can i refresh the rowsource as I am typing in the combo1?
Maybe there is another aproach to this all together...
Thanks for Any help,
Gil


Don't know if this aircode will work but...
Dim strSource as String
Dim strValue As String
Dim intPos As String

strValue = Me.combo1

strSource = Me.Combo1.Rowsource
'remove Where statement
intPos = instr(strSource," Where ")
If intPos > 0 the strSource = left(strSource,intPos)

strSource = strSource & " Where field1 = '" & Me.Combo1 & "'"
Me.Combo1.Rowsource = strSource
'you could check and see if there are any rows returned...then
Me.Combo1 = strValue

Nov 25 '05 #2
Gil wrote:

What i am trying to do is have the combo box filter to the text being
entered.
The combo1 rowsource is:
SELECT * FROM tbl WHERE field1 Like combo1 & "*"

The code looks like this:

Private Sub combo1_Change()
Me.combo1.Requery
End Sub When i do this i get the following error:
"Your must save the current field before you run the requery action."

This is because as you are entering characters, you are changing the
text property of the combo box and not the value.

Of course, I don't know what the purpose of this is within your
application, but I don't think this is a wise idea.

It sounds like you are using the combo for a dual purpose, to narrow the
number of possible choices down AND to make a selection. In my own
(emphasize "my own") experience, users are easily confused by controls
which perform multiple and different functions.

I do the following in a successful app, although it's against a list
box, but it's the same principle.

I put in a separate text box, say txtSearchEnter. To avoid the message
you mention, I then put in a second, _invisible_, text box, say
txtSearch. The purpose of the second text box is to save each change
made to the text. So, in the visible text box into which the user
enters text, I have the on change event as follows:

Private Sub txtSearchEnter_Change()

Me.txtSearch = Me.txtSearchEnter.Text

Me.Combo1.Requery

End Sub

The combo1 (I think you ought to rename this control name to something
that's a bit more intuitive, like cboChoice or something, but that's
your call) rowsource would then be:

SELECT * FROM tbl WHERE field1 Like txtSearch & "*"

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Nov 25 '05 #3
Try this and see if it does what you want ---
1. Remove the Change event code
2. Remove the Where clause from the rowsource and add an ascending sort on
the field you want to display in the combobox
3. Under the Data tab in Properties, change the Autoexpand property to Yes
4. Put the following code in the Enter event of the combobox:
Me.NameOfCombobox.Dropdown

Now try entering something in the combobox.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com

Over 1000 Access users have come to me for help. My fees are very
reasonable.

"Gil" <gi*******@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Hello,
I want a combox to requery each time it is being changed.

What i am trying to do is have the combo box filter to the text being
entered.
The combo1 rowsource is:
SELECT * FROM tbl WHERE field1 Like combo1 & "*"

The code looks like this:

Private Sub combo1_Change()
Me.combo1.Requery
End Sub

When i do this i get the following error:
"Your must save the current field before you run the requery action."

How can i refresh the rowsource as I am typing in the combo1?
Maybe there is another aproach to this all together...
Thanks for Any help,
Gil

Nov 25 '05 #4

"PC Datasheet" <no****@nospam.spam> wrote in message
news:XB****************@newsread3.news.atl.earthli nk.net...
PC Datasheet
[garbage snipped]


The CDMA charter prohibits advertising and Steve is the only consultant that
refuses to adhere to that charter. There are literally hundreds of competent
Access consultants available. Many post regularly in this newsgroup, others
can easily be located by googling or visiting guru.com.

Either Steve's advertising should be stopped or the CDMA charter should be
amended to permit it. Permitting Steve to continue advertising punishes the
many ethical consultants who contribute here but don't advertise.

Nov 25 '05 #5
Randy,

Why don't you follow the advise of David Fenton ---

"Stop. I'm on the verge of killfiling the bunch of you who are
polluting the newsgroup with theis bitchfest."

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com

Over 1000 Access users have come to me for help. My fees are very
reasonable.


"PleaseStopAdvertising" <no****@pcdatasheet.com> wrote in message
news:TQ****************@newssvr24.news.prodigy.net ...

"PC Datasheet" <no****@nospam.spam> wrote in message
news:XB****************@newsread3.news.atl.earthli nk.net...
PC Datasheet
[garbage snipped]


The CDMA charter prohibits advertising and Steve is the only consultant
that
refuses to adhere to that charter. There are literally hundreds of
competent
Access consultants available. Many post regularly in this newsgroup,
others
can easily be located by googling or visiting guru.com.

Either Steve's advertising should be stopped or the CDMA charter should be
amended to permit it. Permitting Steve to continue advertising punishes
the
many ethical consultants who contribute here but don't advertise.

Nov 25 '05 #6
On 25 Nov 2005 09:23:49 -0800, "Gil" <gi*******@gmail.com> wrote:
Hello,
I want a combox to requery each time it is being changed.

What i am trying to do is have the combo box filter to the text being
entered.
The combo1 rowsource is:
SELECT * FROM tbl WHERE field1 Like combo1 & "*"

The code looks like this:

Private Sub combo1_Change()
Me.combo1.Requery
End Sub

When i do this i get the following error:
"Your must save the current field before you run the requery action."

How can i refresh the rowsource as I am typing in the combo1?
Maybe there is another aproach to this all together...
Thanks for Any help,


See if this doesn't have what you need:

http://allenbrowne.com/ser-32.html

mike
Nov 26 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Pete | last post by:
I have a combobox which is used to select records, which is satisfactory at the moment. However, a second user is going to start using this database and there will be 1600 records. This makes...
0
by: luci | last post by:
Hello I've developed several data access pages and I searched for the same problems in different internet pages but I never got back a usable answer. Here are my questions: 1) How is it...
3
by: rmatteson | last post by:
I am trying to figure out how to clear all items from a combobox (Access 2002). On my form, I have to comboboxes. Combobox 2 is populated with a set of child data dependent on the parent data...
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
5
by: ApexData | last post by:
I have a ComboBox, when dblClicked, displays the combobox's row content in a continuous subform. Changes can be made to this content in the subform and then closed. The ComboBox needs to be...
3
by: ApexData | last post by:
COMBOBOX REFRESH DILEMMA ' I have been working for hours trying to figure out how to requery a combobox in a subform, from a Popup form ' that this subform had launched. Basically, I designed...
34
by: bitsnbytes64 | last post by:
Hi, I've been having a similar issue to what is described in the "refresh a form" post with a ComboBox that is not being refreshed after adding a new value on a seperate form. The second form is...
3
by: Eric | last post by:
Hi. I have this Combobox name 'Origin' that contains all states and countries. I would like to create two Radio buttons (State and Country) that when you select State, the combobox will query only...
4
by: EManning | last post by:
I have a combobox whose rowsource is a union query. This query displays a person's name in "lastname, firstname" format and in "firstname lastname" format. The query results look like this: ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.