473,326 Members | 2,337 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,326 software developers and data experts.

Getting ComboBox recordsource filtered by current data in current record.

2
I have a tabbed subform (data sheet view) for which one of the controls is a combo box. It is based on a query that needs to be filtered by the same field data linking the main and sub forms.

I get a parameter entry box which asks for the value and then retains that value when the parent form records are scrolled thru.

I have created a specific query fort the combobox recordsource and have tried several modifications to the WHERE part of the sql statement with no success.

The query is trying to run before before focus is pointed by mouse to any of the records. How can I have the query run only when the combobox is pulled down?

Any help would be appreciated. I have spent better part of two days searching and trying to figure this out.
Mar 5 '08 #1
2 2902
Megalog
378 Expert 256MB
First, build a correct sql statement that will work for your rowsource (I wasnt sure if you were having a problem with this part, if so, please post the specific field & form name information you are working with).

Once you have that, then use the 'On Enter' event to set the combo box rowsource.

For example:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cboSubformBox_Enter()
  2.  
  3. me.cboSubformBox.rowsource = "<insert rowsource SQL here>"
  4.  
  5. End Sub
and I usually pair that with an 'On Exit' event like such:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cboSubformBox_Exit()
  2.  
  3. me.cboSubformBox.rowsource = ""
  4.  
  5. End Sub
So everytime you click that combo box, it's going to requery itself and present you with filtered data off your current criteria. Once this is set, you can delete any code out of the Rowsource property in design view, since it's probably not needed on Load, and will speed things up a bit.
Mar 7 '08 #2
PTMech
2
Thanks,

I have the first part (i think) but the second is whay I am missing.

I'll try it out an let you know if that works.
Mar 10 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

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...
0
by: Susan Bricker | last post by:
The following error: "The current field must match the join key '?' in the table that seves as t the 'one' side of one-to-many relationship. Enter a record in the 'one' side table with the...
2
by: Susan Bricker | last post by:
I went back to read my post and found an error in my description ... here is the post, again, corrected: The following error: "The current field must match the join key '?' in the table that...
6
by: Doug Bell | last post by:
Hi I have a datagrid with a combo box, I need to populate the combo with data dependant on the record value. eg for record 1, field Warehouse = 2R so combo would allow selection of locations...
11
by: DSR | last post by:
Help Please... I would like to populate a combo box on a form with a query that compares data from two tables. Any record that is unique in table1 should continue to populate my combobox. The...
12
by: eetarnold | last post by:
Hi Gurus, As I've read in other posts the past couple of days, I've read many great posts and haven't figured out how I can solve this problem...I'm trying to make a form very user friendly for...
5
by: Rich | last post by:
Hello, I have a search application to search data in tables in a database (3 sql server tables). I populate 2 comboboxes with with data from each table. One combobox will contain unique...
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...
3
by: Thelma Roslyn Lubkin | last post by:
I have a form whose rowsource is a single table, i.e. 'Datasystem'. I use a combobox to search for records in that table based on the value of a single field, i.e., 'systemname'. I use a...
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...
1
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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.