473,320 Members | 1,902 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.

How to refresh the second combo box?

17
Hello guys,

i have made a data entry form with two combo boxes.

The first one called [company ID] from the table [company] with the

row source:
Expand|Select|Wrap|Line Numbers
  1. SELECT [company].[company ID], [company].[company name] FROM company;
  2.  
so i don't need to remember the company ID but can see the company name connect to the company ID instead.

the next combo box is called [subs ID] from the table [subsidiary]
( incl. subs ID, company ID, ...),
which populates the combo box with the correct list of subsidiaries of the company chosen in the first combo box.

row source:
Expand|Select|Wrap|Line Numbers
  1. SELECT subsidiary.[subs ID], company.[company ID], subsidiary.[subs name] LEFT JOIN subsidiary ON company.[company ID]=subsidiary.[subs ID] WHERE ((([company].[company ID])=[Forms]![xxx]![company ID]))
  2.  
this works like a charm, but if i accidentally took the wrong company and wanna change that, the subsidiary list in the second combo box remains the same. it doesn't change to the new situation meaning to the new list of subsidiaries of the new company.

how can i refresh or requery the list of the second combo box???
Jul 5 '15 #1

✓ answered by jimatqsi

In the After Update event of [Forms]![xxx]![company ID]) you will want to put this line of code to requery the 2nd combo box:
Expand|Select|Wrap|Line Numbers
  1. Me.[Subs ID].requery
Do yourself a favor and avoid putting spaces in object names in the future. You won't have to bracket [] everything.

Jim

3 2064
jimatqsi
1,271 Expert 1GB
In the After Update event of [Forms]![xxx]![company ID]) you will want to put this line of code to requery the 2nd combo box:
Expand|Select|Wrap|Line Numbers
  1. Me.[Subs ID].requery
Do yourself a favor and avoid putting spaces in object names in the future. You won't have to bracket [] everything.

Jim
Jul 5 '15 #2
rod4
17
Thanks that was the perfect reply! i was so close but then so far! ;)
the spaces problem is the next item on my lists of problems to solve!
thanks a lot!!!
Jul 5 '15 #3
NeoPa
32,556 Expert Mod 16PB
Please understand this is not advice to ignore what Jim's said, but simply an alternative that you should understand.

Access will also make controls with spaces in their names available by replacing those spaces with underscore (_) characters. Thus, Me.Subs_ID is another way to refer to it.

Far better not to have them though, as you've already agreed.
Jul 5 '15 #4

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

Similar topics

0
by: Alienz | last post by:
Hey, I was reading the google groups for info on this but the explanation left out exactly how to do the query.. Lets say I have table1 with 2 combo boxes combo1 has a value list of: "new",...
15
by: sara | last post by:
Hi I'm pretty new to Access here (using Access 2000), and appreciate the help and instruction. I gave myself 2.5 hours to research online and help and try to get this one, and I am not getting...
0
by: Rosalie Tackett | last post by:
Hello, I need a query that will determine the values in a dropdown box (Module), based on the value chosen in another dropdown box (Dir). SELECT Modules.Module FROM Modules WHERE...
1
by: AA Arens | last post by:
On form 1 I have a button accessing another form 2. Form 1 handles the fill in of compant info starting with choosing a company via combo box. Form 2 is to add another company. When I dismiss...
4
by: jhwa | last post by:
I am a relative newbie to Access. I am creating an inventory and sales database in Access 2007 on Windows XP. I am trying to create two combo boxes on a form, where one is populated with info from...
3
by: mbedford | last post by:
In my asset and employee database I have Departments and Subdepartments. In the forms I want to filter the Subdepartment combo boxes based on the selection in the Department combo box. Combo...
16
by: klbrownie | last post by:
Hello all, I have a subform within a form and I have two combo boxes. the first combo is Facility and the second is Unit. I want the selections for Unit to be determined by the selection in...
5
by: Haagimus | last post by:
I am trying to create an access form that will have multiple combo box drop downs. There are two that will need to be linked in the form. The selection of the first will need to become the query...
6
by: lewisoh | last post by:
I am using Access 2007 trying to use combo box 1 named zone to define which data is shown in combo box 2 named cell. The code is as follows; Private Sub Zone_AfterUpdate() ' Update the row...
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...
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...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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...

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.