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

make two dependent select fields

stephane
i've got two table
ServicesGroups ( id, name ) and
Services ( id, group_id, name )
tables linked on ServicesGroups.id=Services.group_id

at first select field i list ServicesGroups table,
so when user select group i need to reload Services select field, and show only services wich linked to selected group ( Where Services.group_id=ServicesGroups.id )

i realize it so

Expand|Select|Wrap|Line Numbers
  1. sql_str = "SELECT Services.name, Services.id " & _
  2.           "FROM Services " & _
  3.           "WHERE Services.group_id=" & ServiceGroup.Value
  4. Servicefield.RowSource
  5. Servicefield.Requery
  6.  
but making Servicefield.Requery we reload all Services selects at form, but we need reload only Services select at current row of the parent table
Feb 12 '07 #1
5 2588

Feb 12 '07 #2
NeoPa
32,556 Expert Mod 16PB
i've got two table
ServicesGroups ( id, name ) and
Services ( id, group_id, name )
tables linked on ServicesGroups.id=Services.group_id

at first select field i list ServicesGroups table,
so when user select group i need to reload Services select field, and show only services wich linked to selected group ( Where Services.group_id=ServicesGroups.id )

i realize it so

Expand|Select|Wrap|Line Numbers
  1. sql_str = "SELECT Services.name, Services.id " & _
  2.           "FROM Services " & _
  3.           "WHERE Services.group_id=" & ServiceGroup.Value
  4. Servicefield.RowSource
  5. Servicefield.Requery
  6.  
but making Servicefield.Requery we reload all Services selects at form, but we need reload only Services select at current row of the parent table
Your second line of code :
Expand|Select|Wrap|Line Numbers
  1. Servicefield.RowSource
Does not set it to the new SQL code. You need :
Expand|Select|Wrap|Line Numbers
  1. Servicefield.RowSource = sql_str
Feb 12 '07 #3
oh
it's a error on posing.
in my real code there are
Servicefield.RowSource = sql_str

this code reloads all services select fields
Feb 12 '07 #4
Michael R
176 100+
I'm not sure how what you ask is possible considering the nature of forms, but you can try the following alternative:

(1) Create table Services:

Service_Id (Autonumber (can as well be entered by user), Primary Key)
Group_Id (Number) or (Text)
Service_Name (Text)

each record will have a service name and its apropriate service group

(2) Create table Selection:

Selection_Id (Autonumber (can as well be entered by user), Primary Key)
Selection (Text), you can also make it a Combo Box in Lookup, and make its Row Source:

SELECT Services.Service_Name, Services.Group_Id FROM Services

with Column Count of 2 for looking up for all possible serivices from Services table, but it is not nescasary for the form.

Add all the other fields you need for creating selections in the form, ex:
Field3
Field4


(3) Create query qrySelection:

SELECT Selection.Selection, Selection.Field3, Selection.Field4, Services.Group_Id
FROM Selection LEFT JOIN Services ON Selection.Selection = Services.Service_Name;

Save it.


(4) Create a continuous form myForm based on qrySelection:

On form's header or footer add a Combo Box named cboGroup_Id with the following Row Source:

SELECT DISTINCT Services.Group_Id FROM Services;

Put Selection field control and Group_Id field control and all the other necessary field controls into detail section. Change Selection control (if it is not already) to Combo Box, with the following Row Source:

SELECT Services.Service_Name FROM Services WHERE (((Services.Group_Id)=Forms!myForm!cboGroup_Id));

Add
Expand|Select|Wrap|Line Numbers
  1. Me.Selection.Requery
to cboGroup_Id On Change event.

---
Now the form should work by user choosing the Group_Id from cboGroup_Id having the appropriate service names on the rows and the service groups according to them.
Feb 12 '07 #5
Michael R
176 100+
Comment on:
I'm not sure how what you ask is possible considering the nature of forms
- What I really mean is, that I'm not entirely sure if what you ask is possible with your current building. Maybe it is possible with some deep ADO programming, but the solution I gave you is pretty simple (well at least for those who aren't expertized in ADO programming)
Feb 12 '07 #6

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

Similar topics

11
by: Randell D. | last post by:
Folks, I have seven text boxes which will contain measurements - I would like the user to input their values in the order that I have listed the boxes. How can I therefore make an input...
5
by: Randy A. Bohannon | last post by:
I have two fields on a form: GPA and Points. GPA will be entered by the user. I would like Points to be filled automatically depending on the value of GPA. For example, the following code...
3
by: Amp Inthalangsy | last post by:
Hi there, Was hoping someone would have an fix for me or some kind or work around. I was able to get my client side dynamic dependent list box working but if my child list data has double...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
0
by: Jim M | last post by:
I have an appointment scheduling application with a number of queries that filter through a table with many thousand appointments and comes up with one days schedule. I need to start out by finding...
8
by: Cerian | last post by:
Hi there, I'm having trouble getting my 3rd dependent combo box to work in Access 2003. I have three dependent boxes named cbogroup, cbosection and cbofunction. Each one is dependent on the...
48
by: coool | last post by:
Hi I'm now trying to have a dependent lists in a form my form is a query based form i.e. I fill my MySQL query from this form I have around 30 fields/columns
4
by: shreyansghia | last post by:
Hello , I ve a form which is based on a table viz SalesOrder. 1 of the field which Sales Order has is : Client. I ve 2 more tables, (a) Client which has 1 field viz ClientName , (b)...
1
by: jmartmem | last post by:
Greetings, I have a nagging problem with client-side dynamic dependent list boxes that perhaps someone can help me troubleshoot. I have a form with a series of dynamic dependent list boxes....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
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
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
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.