473,416 Members | 1,486 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.

Combo box behavior on continuous form

I have a child form that has a combo box whose underlying query needs
to be filtered by a value from a combo box on the parent form.

I have succeeded in doing this by putting the following SQL in the
rowsource of the combobox:

SELECT tblForms.idForms, tblForms.FormNumber, tblForms.FormName,
tblForms.idCustomers FROM tblForms ORDER BY tblForms.FormNumber;

Then I adding the following to the GotFocus event of the combo box and
the Current event of the form:

cboidForms.RowSource = "qryDesignOrderDropDown"
cboidForms.Requery

This works but is real kludgy. Whenever I change parent records, it has
a noticeable delay while it requeries for each record in the child
form.

Surely there's a better way to have a child form's combobox query be
filtered based on a value from a combobox on the parent form.

Nov 13 '05 #1
4 5541
In the Enter event of the combo in the subform, set its RowSource to a SQL
statement. Something like this:

Dim strSql As String
With Me.Parent![MyMainFormCombo]
strSql = "SELECT Field1, Field2 FROM MyCombosTable WHERE " & _
IIf(IsNull(.Value), "(False)", "SomeID = " & .Value) & ";"
End With
Me.[MySubformCombo].RowSource = strSql
That should be all you need unless the combo's bound column is zero-width.
In that case you would need to do the same in the Current event of the main
form as well, so that the other values show up in the combo as well.

That's not very different from what you are doing. But assigning the SQL
directly may be quicker than going through a query. If there are thousands
of records to load into the combo, it might be worthwhile checking whether
it needs to be reloaded, i.e.:
With Me.[MySubformCombo]
If .RowSource <> strSql then
.RowSource = strSql
End If
End With

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<jc*************@yahoo.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
I have a child form that has a combo box whose underlying query needs
to be filtered by a value from a combo box on the parent form.

I have succeeded in doing this by putting the following SQL in the
rowsource of the combobox:

SELECT tblForms.idForms, tblForms.FormNumber, tblForms.FormName,
tblForms.idCustomers FROM tblForms ORDER BY tblForms.FormNumber;

Then I adding the following to the GotFocus event of the combo box and
the Current event of the form:

cboidForms.RowSource = "qryDesignOrderDropDown"
cboidForms.Requery

This works but is real kludgy. Whenever I change parent records, it has
a noticeable delay while it requeries for each record in the child
form.

Surely there's a better way to have a child form's combobox query be
filtered based on a value from a combobox on the parent form.

Nov 13 '05 #2
Thanks for the tip. Unfortunately, the code isn't quite fully
functional.

As you guessed, my combo's bound column is zero length so at your
suggestion, I duplicated the code in the parent's Current event.
Naturally I had to include a reference to the subform because the combo
on the subform is not part of the parent. So, here's the offending
line:

Me.frmOrdersDesignSubForm![cboidForms].RowSource = strSQL

If I open the parent from Design mode, it works perfectly. However,
when I try to open the parent form from the database window, I get an
error message about an invalid reference, presumably because the link
between parent and child has not yet been established (though IMHO, it
should be)

So the question is, how do I get the parent to hold off on the
assignment of the SQL statement until the subform is loaded?

Nov 13 '05 #3
Try:
Me.frmOrdersDesignSubForm.Form![cboidForms].RowSource = strSQL

Explanation of the ".Form" bit:
http://allenbrowne.com/casu-04.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<jc*************@yahoo.com> wrote in message
news:11*********************@l41g2000cwc.googlegro ups.com...
Thanks for the tip. Unfortunately, the code isn't quite fully
functional.

As you guessed, my combo's bound column is zero length so at your
suggestion, I duplicated the code in the parent's Current event.
Naturally I had to include a reference to the subform because the combo
on the subform is not part of the parent. So, here's the offending
line:

Me.frmOrdersDesignSubForm![cboidForms].RowSource = strSQL

If I open the parent from Design mode, it works perfectly. However,
when I try to open the parent form from the database window, I get an
error message about an invalid reference, presumably because the link
between parent and child has not yet been established (though IMHO, it
should be)

So the question is, how do I get the parent to hold off on the
assignment of the SQL statement until the subform is loaded?

Nov 13 '05 #4
Thanks, again, but unfortunately, something must be wrong with my
system. I made the change you suggested but I'm still getting:

runtime error: 2455
you entered an expression that has an invalid reference t the property
Form/Report.

I read the link you provided and I even went to the MS knowledge base:

http://support.microsoft.com/kb/q113352/
That page shows what you suggested, namely, to type:

Forms![main form name]![subform control name].Form![control name]

But I still get the error message. So...something must be wrong with my
MS Access installation.

Thoughts?

Nov 13 '05 #5

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

Similar topics

4
by: Heather | last post by:
Hi I am desparately looking for advice in relation to storing the results after selecting items from two combo boxes on a Referral form. The first combo box 'ctl Type' displays a full list of...
3
by: B | last post by:
I know there are several ways to speed up combo boxes and form loading. Most of the solutions leave rowsource of the combo box blank and set the rowsource to a saved query or an SQL with a where...
1
by: Giulio | last post by:
Hello, I have a continuous form with a combo box inside. From the combo box I can pick some values which, by the "after-update" event, change some other combo box values determined by a query....
3
by: NB | last post by:
Let's say in the product table I have around 50,000 products (well, infact it has now about 2000 only, but it's growing very fast, hence the question here) In the order form, users will select...
5
by: mik18 | last post by:
Is there a limit to the number of rows a combo box can contain within Access 2002? I have a list of drug names with all the NDC codes which contains over 200,000 records. I do have this filtered...
9
by: Edwinah63 | last post by:
Hi everyone, Please let there be someone out there who can help. I have two BOUND combo boxes on a continuous form, the second being dependent on the first. I have no problem getting the...
0
by: Jeremy Wallace | last post by:
Folks, Here's a write-up I did for our developer wiki. I don't know if the whole rest of the world has already figured out how to do this, but I hadn't ever seen it implemented, and had spent a...
1
by: Bill | last post by:
Problem: Combo box data disappears from view when a requery is done See "Background" below for details on tables, forms & controls On a form, I want to use the setting of bound combo box C1...
4
by: virtualgreek | last post by:
Dear All, First of all I would like to take the time to thank you all for your efforts and time spent at this wonderful forum. I have found it very helpful with numerous examples available for...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.