Basing one combobox on another

G

Guest

I have a form that contains 2 cmb's (cmbActReg and cmbSection) and 1 textbox
(txtDescription). What I am trying to do is have the second combobox display
a number of items based on a selection made in the First box. I have found
an example on MSDN regarding this and have followed it step by step but it
still does not seem to work.

My Form is called "Offence Details".
This form is based off of two tables
1) Act/Regs - this table contains 22 seperate acts and/or regulations.
2) Legislation - this table contains the various sections of the 22 act/regs
listed in the previous table.

I have a 1-to-many relationship between the Act/Reg and Legislations tables
based on the ID (primary key) in the Act/Reg table (the foreign key in the
Legislation table is called ActRegID).

On the Form I have set the RowSource properties of cmbActReg to:
SELECT [Acts/Regs].ID, [Acts/Regs].[Acts and Regulations] FROM [Acts/Regs];

For cmbSection the RowSource properties are set as:
SELECT Legislation.ID, Legislation.ActRegID, Legislation.Section FROM
Legislation WHERE (((Legislation.ActRegID)=forms![Warnings
Issued]!cmbActReg)) ORDER BY Legislation.Section;

When I open the form I am prompted to enter the criteirs for the above
queries. When I enter the information noting happens.

Can someone provide somw assistance with this? What I woudl like to have
happen is that the query is run automatically (as it was in the example I
read on the Web).

Z
 
G

Guest

You wrote that the form name is - Offence Details, so change the row source
of the second combo to

SELECT Legislation.ID, Legislation.ActRegID, Legislation.Section FROM
Legislation WHERE (((Legislation.ActRegID)=forms![Offence
Details]!cmbActReg)) ORDER BY Legislation.Section

Also, on the after update event of the first combo you need to refresh combo 2

Me.[cmbSection].Requery
 
G

Guest

Thanks very much - I've been banging my head on my screen for the past hour!!
(a little logic goes a long way!!)

Thanks again.

Z



Ofer Cohen said:
You wrote that the form name is - Offence Details, so change the row source
of the second combo to

SELECT Legislation.ID, Legislation.ActRegID, Legislation.Section FROM
Legislation WHERE (((Legislation.ActRegID)=forms![Offence
Details]!cmbActReg)) ORDER BY Legislation.Section

Also, on the after update event of the first combo you need to refresh combo 2

Me.[cmbSection].Requery

--
Good Luck
BS"D


Zoltar54 said:
I have a form that contains 2 cmb's (cmbActReg and cmbSection) and 1 textbox
(txtDescription). What I am trying to do is have the second combobox display
a number of items based on a selection made in the First box. I have found
an example on MSDN regarding this and have followed it step by step but it
still does not seem to work.

My Form is called "Offence Details".
This form is based off of two tables
1) Act/Regs - this table contains 22 seperate acts and/or regulations.
2) Legislation - this table contains the various sections of the 22 act/regs
listed in the previous table.

I have a 1-to-many relationship between the Act/Reg and Legislations tables
based on the ID (primary key) in the Act/Reg table (the foreign key in the
Legislation table is called ActRegID).

On the Form I have set the RowSource properties of cmbActReg to:
SELECT [Acts/Regs].ID, [Acts/Regs].[Acts and Regulations] FROM [Acts/Regs];

For cmbSection the RowSource properties are set as:
SELECT Legislation.ID, Legislation.ActRegID, Legislation.Section FROM
Legislation WHERE (((Legislation.ActRegID)=forms![Warnings
Issued]!cmbActReg)) ORDER BY Legislation.Section;

When I open the form I am prompted to enter the criteirs for the above
queries. When I enter the information noting happens.

Can someone provide somw assistance with this? What I woudl like to have
happen is that the query is run automatically (as it was in the example I
read on the Web).

Z
 
G

Guest

I have ecountered yet another problem.

The boxes funtion correctly but I now need to have the selected items be
added to a record. I have incorporated the Offence form as a subForm on the
Parent (Warnings). I have also added 3 new textboxes to the parent form.
These new items will list the items selected from the sunform.

The problem is that I cannot seem to get the items in the three new text
boxes on the Parent form to add to the record.

Any assistance would e greatly appreciated.

Z

Ofer Cohen said:
You wrote that the form name is - Offence Details, so change the row source
of the second combo to

SELECT Legislation.ID, Legislation.ActRegID, Legislation.Section FROM
Legislation WHERE (((Legislation.ActRegID)=forms![Offence
Details]!cmbActReg)) ORDER BY Legislation.Section

Also, on the after update event of the first combo you need to refresh combo 2

Me.[cmbSection].Requery

--
Good Luck
BS"D


Zoltar54 said:
I have a form that contains 2 cmb's (cmbActReg and cmbSection) and 1 textbox
(txtDescription). What I am trying to do is have the second combobox display
a number of items based on a selection made in the First box. I have found
an example on MSDN regarding this and have followed it step by step but it
still does not seem to work.

My Form is called "Offence Details".
This form is based off of two tables
1) Act/Regs - this table contains 22 seperate acts and/or regulations.
2) Legislation - this table contains the various sections of the 22 act/regs
listed in the previous table.

I have a 1-to-many relationship between the Act/Reg and Legislations tables
based on the ID (primary key) in the Act/Reg table (the foreign key in the
Legislation table is called ActRegID).

On the Form I have set the RowSource properties of cmbActReg to:
SELECT [Acts/Regs].ID, [Acts/Regs].[Acts and Regulations] FROM [Acts/Regs];

For cmbSection the RowSource properties are set as:
SELECT Legislation.ID, Legislation.ActRegID, Legislation.Section FROM
Legislation WHERE (((Legislation.ActRegID)=forms![Warnings
Issued]!cmbActReg)) ORDER BY Legislation.Section;

When I open the form I am prompted to enter the criteirs for the above
queries. When I enter the information noting happens.

Can someone provide somw assistance with this? What I woudl like to have
happen is that the query is run automatically (as it was in the example I
read on the Web).

Z
 
G

Guest

Have you selected in the control source of each text box the related field
from the table where you want this value to be saved in.
It sound that he fields are UnBound, they are not connected to any field in
the table.

--
Good Luck
BS"D


Zoltar54 said:
I have ecountered yet another problem.

The boxes funtion correctly but I now need to have the selected items be
added to a record. I have incorporated the Offence form as a subForm on the
Parent (Warnings). I have also added 3 new textboxes to the parent form.
These new items will list the items selected from the sunform.

The problem is that I cannot seem to get the items in the three new text
boxes on the Parent form to add to the record.

Any assistance would e greatly appreciated.

Z

Ofer Cohen said:
You wrote that the form name is - Offence Details, so change the row source
of the second combo to

SELECT Legislation.ID, Legislation.ActRegID, Legislation.Section FROM
Legislation WHERE (((Legislation.ActRegID)=forms![Offence
Details]!cmbActReg)) ORDER BY Legislation.Section

Also, on the after update event of the first combo you need to refresh combo 2

Me.[cmbSection].Requery

--
Good Luck
BS"D


Zoltar54 said:
I have a form that contains 2 cmb's (cmbActReg and cmbSection) and 1 textbox
(txtDescription). What I am trying to do is have the second combobox display
a number of items based on a selection made in the First box. I have found
an example on MSDN regarding this and have followed it step by step but it
still does not seem to work.

My Form is called "Offence Details".
This form is based off of two tables
1) Act/Regs - this table contains 22 seperate acts and/or regulations.
2) Legislation - this table contains the various sections of the 22 act/regs
listed in the previous table.

I have a 1-to-many relationship between the Act/Reg and Legislations tables
based on the ID (primary key) in the Act/Reg table (the foreign key in the
Legislation table is called ActRegID).

On the Form I have set the RowSource properties of cmbActReg to:
SELECT [Acts/Regs].ID, [Acts/Regs].[Acts and Regulations] FROM [Acts/Regs];

For cmbSection the RowSource properties are set as:
SELECT Legislation.ID, Legislation.ActRegID, Legislation.Section FROM
Legislation WHERE (((Legislation.ActRegID)=forms![Warnings
Issued]!cmbActReg)) ORDER BY Legislation.Section;

When I open the form I am prompted to enter the criteirs for the above
queries. When I enter the information noting happens.

Can someone provide somw assistance with this? What I woudl like to have
happen is that the query is run automatically (as it was in the example I
read on the Web).

Z
 
G

Guest

When I connect the text boxes to the record table (called Warnings) I am not
able to have the items listed on the subForm(Offence Details) transfer over.

I imagine this needs to be done programmatically.

I have tried to add the following line of code into the "AfterUpdate"
procedure in the subform:

Warnings_Issued.txtSection=Me.cmbSection.itemdata(0)

I should mention as well that it will be neccesary to add multiple records
from the subform to the parent form.

Again, I very much appreciate all the help.

Z

However when I run the form I get an error "Object required"

Ofer Cohen said:
Have you selected in the control source of each text box the related field
from the table where you want this value to be saved in.
It sound that he fields are UnBound, they are not connected to any field in
the table.

--
Good Luck
BS"D


Zoltar54 said:
I have ecountered yet another problem.

The boxes funtion correctly but I now need to have the selected items be
added to a record. I have incorporated the Offence form as a subForm on the
Parent (Warnings). I have also added 3 new textboxes to the parent form.
These new items will list the items selected from the sunform.

The problem is that I cannot seem to get the items in the three new text
boxes on the Parent form to add to the record.

Any assistance would e greatly appreciated.

Z

Ofer Cohen said:
You wrote that the form name is - Offence Details, so change the row source
of the second combo to

SELECT Legislation.ID, Legislation.ActRegID, Legislation.Section FROM
Legislation WHERE (((Legislation.ActRegID)=forms![Offence
Details]!cmbActReg)) ORDER BY Legislation.Section

Also, on the after update event of the first combo you need to refresh combo 2

Me.[cmbSection].Requery

--
Good Luck
BS"D


:

I have a form that contains 2 cmb's (cmbActReg and cmbSection) and 1 textbox
(txtDescription). What I am trying to do is have the second combobox display
a number of items based on a selection made in the First box. I have found
an example on MSDN regarding this and have followed it step by step but it
still does not seem to work.

My Form is called "Offence Details".
This form is based off of two tables
1) Act/Regs - this table contains 22 seperate acts and/or regulations.
2) Legislation - this table contains the various sections of the 22 act/regs
listed in the previous table.

I have a 1-to-many relationship between the Act/Reg and Legislations tables
based on the ID (primary key) in the Act/Reg table (the foreign key in the
Legislation table is called ActRegID).

On the Form I have set the RowSource properties of cmbActReg to:
SELECT [Acts/Regs].ID, [Acts/Regs].[Acts and Regulations] FROM [Acts/Regs];

For cmbSection the RowSource properties are set as:
SELECT Legislation.ID, Legislation.ActRegID, Legislation.Section FROM
Legislation WHERE (((Legislation.ActRegID)=forms![Warnings
Issued]!cmbActReg)) ORDER BY Legislation.Section;

When I open the form I am prompted to enter the criteirs for the above
queries. When I enter the information noting happens.

Can someone provide somw assistance with this? What I woudl like to have
happen is that the query is run automatically (as it was in the example I
read on the Web).

Z
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top