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

my problem with two dynamic combobox

Hello. I am facing a problem in access that cost me delay one week to submit my project of inventory database that I make it for computer device that used in our department.

I make combobox, name it(brand name)of computer company. other combobox that show you the model of computer. I want when user select the name of computer company then the next combobox of model display only the model of that company.

The problem is for example when I select hp copmany and I go to next combobox that will show me onle the model of hp but the model of hp for ex is :

1- dv5
2-dv6
3-pavilion 3847

when I select the second or third model then will only select the first one to fill the combobox so I need way to make combobox select any item of combobox.

I hope you understand to me.

Thank you.
Aug 5 '10 #1
13 3122
Steven Kogan
107 Expert 100+
This requires VBA coding.

The recordsource of the second combo box (Combo2) would need to filter depending on the value of the first combo box (Combo1).

You could use the after update event of the first combo box to change the recordsource of the second combo box accordingly.

The code would be something like this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo1_AfterUpdate()
  2.     If Nz(Combo1, "") = "" Then
  3.         Combo2.RowSource = ""
  4.     Else
  5.         Combo2.RowSource = "SELECT Test2.ID, Test2.Field1 " _
  6.         & "FROM Test2 WHERE (((Test2.TestID) = " _
  7.         & [Forms]![Parameters]![Combo1] & ")) " _
  8.         & "ORDER BY Test2.Field1;"
  9.     End If
  10. End Sub
If you need more specific code, please provide me with the current RowSource of your second combo box, the name of the form, and the names of the two combo boxes.
Aug 5 '10 #2
thank you steven to help me

i need specific code please
becuase i don't understrand the varible clearly hear

i don't understand the recordsource you want

do you mean the row source or the control source!!

the row source is Model Query
the control Source is Device Information_model

name of form is GQ Form

the first combobox name is BC
the secomd combobox name is MC


thank you...
Aug 6 '10 #3
NeoPa
32,556 Expert Mod 16PB
Why don't you play around with Example Filtering on a Form for a while. It should help you understand the issues clearly enough to handle this problem.

PS. Please do not request help via instant messaging. This is against site rules and will not be tolerated as it is inconsiderate of our experts.
Aug 6 '10 #4
Steven Kogan
107 Expert 100+
You are right - I meant RowSource of the 2nd combobox MC.

Can you provide the SQL of "Model Query"? The code would be modified so that the Where clause restricts values according to the contents of the first combobox BC.

The code would be something like:

Expand|Select|Wrap|Line Numbers
  1. Private Sub BC_AfterUpdate()
  2.     If Nz(BC, "") = "" Then
  3.         MC.RowSource = ""
  4.     Else
  5.         MC.RowSource = "SELECT * " _
  6.         & "FROM [Model Query] WHERE (((BrandID) = " _
  7.         & [Forms]![GQ Form]![BC] & ")) " _
  8.         & "ORDER BY ModelName;"
  9.     End If
  10. End Sub
  11.  
If Model Query already has a filter that references [Forms]![GQ Form]![BC] then your code could be:

Expand|Select|Wrap|Line Numbers
  1. Private Sub BC_AfterUpdate()
  2.     MC.Requery
  3. End Sub
  4.  
Aug 6 '10 #5
hello

can any one tell me how i can make parameter read the value from combobox???

that the problem i faced now to i can filter the model!
Aug 9 '10 #7
NeoPa
32,556 Expert Mod 16PB
I'm sorry. What do you mean?
Aug 9 '10 #8
the answer of members doesn't help me

i try to find other way

i put the code of query

when i select the hp in brand name
and go to model
the window of parameter pop up so when i write hp in parameter filter the model
then only the model of hp shown

i whant make it read the parameter from brand name!
Aug 9 '10 #9
NeoPa
32,556 Expert Mod 16PB
Do you mean you'd like the Model ComboBox to be filtered such that it only shows those models that are relevant to the Brand?

If so, then that will involve filtering and referencing controls on your form. It's a bit difficult to proceed with you in that direction as you haven't told us any information that we would need, such as the names of your controls and how you have the form set up at the moment.

I can see that English is a bit of a problem for you. We can understand that. This information is not to do with language difficulties though. Just listing the names of the controls would be a good start.
Aug 9 '10 #10
Steven Kogan
107 Expert 100+
Hi Aks 2010,

I notice you reposted your question, but in this thread you should be close to a solution.

Can you post the SQL for the query 'Model Query'? You wrote that Model Query is the rowsource for the 2nd combobox, named MC.
Aug 10 '10 #11
hi steven

the SQL of Model Query is:
Expand|Select|Wrap|Line Numbers
  1. SELECT Model.MCode, Model.BModel, Brand.BCode, Brand.[Brand Name]
  2. FROM Brand INNER JOIN Model ON Brand.[Brand Name] = Model.Bcode;
---
yes that query for 2nd combobox but now named BM Q
becuse i make it with the table of brand name to i can filter that model

also the first combobox is related to the Brand Query

i hope you can help me with it


thank you...
Aug 10 '10 #12
Steven Kogan
107 Expert 100+
For this to work the first combo box would be named BC, and it should contain the Brand.Bcode (even though it displays the brand).

Expand|Select|Wrap|Line Numbers
  1. Private Sub BC_AfterUpdate() 
  2.     If Nz(BC, "") = "" Then 
  3.         [BM Q].RowSource = "" 
  4.     Else 
  5.         [BM Q].RowSource = "SELECT Model.MCode, Model.BModel, Brand.BCode, Brand.[Brand Name] " _ 
  6.         & "FROM Brand INNER JOIN Model ON Brand.[Brand Name] = Model.Bcode " _ 
  7.         & "WHERE (((Brand.Bcode) = " & me.[BC] & ")) " _ 
  8.         & "ORDER BY Model.BModel;" 
  9.     End If 
  10. End Sub 
  11.  
Hopefully this works for you.
Aug 10 '10 #13
NeoPa
32,556 Expert Mod 16PB
I would like to bring to the attention of anyone helping in here that the OP has created a new thread (Filtering the two queries in two combobox) where they had hoped to get an answer to this same problem. With their general lack of willingness to respond to requests for information (or at all generally) I have no further interest in this thread on a technical level.
Aug 11 '10 #14

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

Similar topics

12
by: Phil Powell | last post by:
The customer made a wild request: they want on their admin panel a textarea that will display an existing resume. This textarea, however, must have a dynamic width, one that "fills the screen...
4
by: John Pether (john | last post by:
Hi I have a page that displays business listings. I have a repeater with dynamic text and in the 4th column I have an email and website link. Both display properly but I need to have one take...
3
by: JOSEPHINE ALVAREZ | last post by:
I have this code that I want to use to do a rollover. However, because the company I am doing it for is continually changing the text, I want to be able to use dynamic text to change the text on...
1
by: gus kernot | last post by:
I have copied code from the MS Knowledge Base that produces the above report. I understand the code and am pretty comfortable working with recordsets. I used the same report structure...
1
by: davidw | last post by:
I found it seems there is a way to create a class with dynamic properties, I don't really need define each property? In ASP.NET, Profile is created with all profile items in web.config as its...
5
by: mk | last post by:
Hi all, The requirement is like this.. I have to update the table with the parameters from front end like at some times i need to update one parameters and some times i have to update more...
5
by: Ronald S. Cook | last post by:
I've read a few posts on the stored procedure vs dynamic sql debate. I ran a few performance test for myself and it appears to be a wash. Given that, I'm leaning toward dynamic sql mostly...
0
by: Davilean | last post by:
Hi, I have got a combobox which directs to another page on select and when the submit button is clicked. I am trying to change it into a dynamic combobox which redirects you to another page on...
20
by: sirsnorklingtayo | last post by:
hi guys please help about Linked List, I'm having trouble freeing the allocated memory of a single linked list node with a dynamic char* fields, it doesn't freed up if I use the FREE()...
0
by: CNSZU | last post by:
Hello all, Does anyone know how to attach a datasource to a combobox that resides in a toolstripdropdownbutton? With fMain.ToolStripComboBox1.ComboBox .DataSource = dv ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
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
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...

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.