Load combobox based on selection

G

Guest

I am working with a databse that has 22 seperate tables. On my form I have a
combobox that is titled Acts and Regulations. This combobox is populated
with data from one table. When one of the options is selected I would like
to load a second combobox with the corresponding date eg: when Financial
Tracking Regulations is selected I want the second combobox to be populated
by the table titled Financial Regulations.

Can someone help me with this?

Z
 
G

Guest

Joan,

Thnaks for the tip. I have entered the code (using the names of my objects)
and it does not seem to work. Below is the code. Can you provide some
further insight?

Z

Dim ssql As String

ssql = "SELECT sectionID, actregID, section, description" & "From tblCAPS
WHERE actregID=&me.ActReg" & "ORDER BY section,description"

Me.Sect.RowSource = ssql
 
J

Joan Wild

ssql = "SELECT sectionID, actregID, section, description From
tblCAPS WHERE actregID= " & me.ActReg & " ORDER BY section,description"

You have misplaced '&' and quotes.
 
G

Guest

Joan,

Thanks once again. The code no longer gives me an error, however it will
not load the data in the tbl CAPS. As I am quite new at the VBA and Access
world perhaps I am missing something. The item called tblCAPS - this is the
taable I want loaded when a particular Item is selected from the first
combobox. Does this need to defined (Dim) and if so what do I define it as
(recordset, access object etc..)

Z
 
J

Joan Wild

You've confused me now. Why are you trying to load a table.?

I thought you had a form with a combobox named [Acts and Regulations] and a
second named (actually I don't know what it's named but it contains
Financial Regulations). You want to make a selection in the Acts and
Regulations combobox, that then restricts the list of values to select in
the second combobox.

Please explain how the tblCAPS comes in to play.
 
G

Guest

I tend to do that.

The items in the Acts and Regulations box are loaded from a single data
table. Each item in the list refers to a seperate table. In this case when
the item CAPS is selected from the first combobox, I would like to have the
records in the table called CAPS to be loaded into the second combobox called
"Section".

I hope this is a little bit clearer.

Z

Joan Wild said:
You've confused me now. Why are you trying to load a table.?

I thought you had a form with a combobox named [Acts and Regulations] and a
second named (actually I don't know what it's named but it contains
Financial Regulations). You want to make a selection in the Acts and
Regulations combobox, that then restricts the list of values to select in
the second combobox.

Please explain how the tblCAPS comes in to play.


--
Joan Wild
Microsoft Access MVP
Joan,

Thanks once again. The code no longer gives me an error, however it
will not load the data in the tbl CAPS. As I am quite new at the VBA
and Access world perhaps I am missing something. The item called
tblCAPS - this is the taable I want loaded when a particular Item is
selected from the first combobox. Does this need to defined (Dim)
and if so what do I define it as (recordset, access object etc..)

Z
 
J

Joan Wild

One doesn't 'load a table' into a combobox, exactly.

Keep going. Suppose the second combo box listed all the records in the CAPS
table. Then what do you want to do?

Also, what happened to the Financial Regulations combobox?


--
Joan Wild
Microsoft Access MVP
I tend to do that.

The items in the Acts and Regulations box are loaded from a single
data table. Each item in the list refers to a seperate table. In this
case when the item CAPS is selected from the first combobox, I would
like to have the records in the table called CAPS to be loaded into
the second combobox called "Section".

I hope this is a little bit clearer.

Z

Joan Wild said:
You've confused me now. Why are you trying to load a table.?

I thought you had a form with a combobox named [Acts and
Regulations] and a second named (actually I don't know what it's
named but it contains Financial Regulations). You want to make a
selection in the Acts and Regulations combobox, that then restricts
the list of values to select in the second combobox.

Please explain how the tblCAPS comes in to play.


--
Joan Wild
Microsoft Access MVP
Joan,

Thanks once again. The code no longer gives me an error, however it
will not load the data in the tbl CAPS. As I am quite new at the
VBA and Access world perhaps I am missing something. The item
called tblCAPS - this is the taable I want loaded when a particular
Item is selected from the first combobox. Does this need to
defined (Dim) and if so what do I define it as (recordset, access
object etc..)

Z

:

ssql = "SELECT sectionID, actregID, section, description From
tblCAPS WHERE actregID= " & me.ActReg & " ORDER BY
section,description"

You have misplaced '&' and quotes.


--
Joan Wild
Microsoft Access MVP

Zoltar54 wrote:
Joan,

Thnaks for the tip. I have entered the code (using the names of
my objects) and it does not seem to work. Below is the code.
Can you provide some further insight?

Z

Dim ssql As String

ssql = "SELECT sectionID, actregID, section, description" & "From
tblCAPS WHERE actregID=&me.ActReg" & "ORDER BY
section,description"

Me.Sect.RowSource = ssql

:

See
http://www.pacificdb.com.au/MVP/Code/ComboRS.htm

--
Joan Wild
Microsoft Access MVP

Zoltar54 wrote:
I am working with a databse that has 22 seperate tables. On my
form I have a combobox that is titled Acts and Regulations.
This combobox is populated with data from one table. When one
of the options is selected I would like to load a second
combobox with the corresponding date eg: when Financial
Tracking Regulations is selected I want the second combobox to
be populated by the table titled Financial Regulations.

Can someone help me with this?

Z
 
G

Guest

Once the user has made a selection from the combobox called "Section" I want
this item to be entered into a table called "Infraction" in a field called
"Section".

The Financial Regulations Combobox is now called Acts and Regulations.

z

Joan Wild said:
One doesn't 'load a table' into a combobox, exactly.

Keep going. Suppose the second combo box listed all the records in the CAPS
table. Then what do you want to do?

Also, what happened to the Financial Regulations combobox?


--
Joan Wild
Microsoft Access MVP
I tend to do that.

The items in the Acts and Regulations box are loaded from a single
data table. Each item in the list refers to a seperate table. In this
case when the item CAPS is selected from the first combobox, I would
like to have the records in the table called CAPS to be loaded into
the second combobox called "Section".

I hope this is a little bit clearer.

Z

Joan Wild said:
You've confused me now. Why are you trying to load a table.?

I thought you had a form with a combobox named [Acts and
Regulations] and a second named (actually I don't know what it's
named but it contains Financial Regulations). You want to make a
selection in the Acts and Regulations combobox, that then restricts
the list of values to select in the second combobox.

Please explain how the tblCAPS comes in to play.


--
Joan Wild
Microsoft Access MVP

Zoltar54 wrote:
Joan,

Thanks once again. The code no longer gives me an error, however it
will not load the data in the tbl CAPS. As I am quite new at the
VBA and Access world perhaps I am missing something. The item
called tblCAPS - this is the taable I want loaded when a particular
Item is selected from the first combobox. Does this need to
defined (Dim) and if so what do I define it as (recordset, access
object etc..)

Z

:

ssql = "SELECT sectionID, actregID, section, description From
tblCAPS WHERE actregID= " & me.ActReg & " ORDER BY
section,description"

You have misplaced '&' and quotes.


--
Joan Wild
Microsoft Access MVP

Zoltar54 wrote:
Joan,

Thnaks for the tip. I have entered the code (using the names of
my objects) and it does not seem to work. Below is the code.
Can you provide some further insight?

Z

Dim ssql As String

ssql = "SELECT sectionID, actregID, section, description" & "From
tblCAPS WHERE actregID=&me.ActReg" & "ORDER BY
section,description"

Me.Sect.RowSource = ssql

:

See
http://www.pacificdb.com.au/MVP/Code/ComboRS.htm

--
Joan Wild
Microsoft Access MVP

Zoltar54 wrote:
I am working with a databse that has 22 seperate tables. On my
form I have a combobox that is titled Acts and Regulations.
This combobox is populated with data from one table. When one
of the options is selected I would like to load a second
combobox with the corresponding date eg: when Financial
Tracking Regulations is selected I want the second combobox to
be populated by the table titled Financial Regulations.

Can someone help me with this?

Z
 
J

Joan Wild

OK, so your form needs to be bound to the Infraction table (or a query that
includes it and the Section field).
The Section Combobox would be bound to the Section field.
The Acts and Regulations combobox would be unbound.
You select an item from this combobox and in turn the items available in the
Section combobox are limited by what you selected in the Acts and
Regulations combobox. Once you select an item in the Section combobox, it
would be stored in the Section field of the Infraction table.

If this doesn't help you, you need to post the details of your form and
comboboxes. It would also help to explain your tables and how they are
related.

--
Joan Wild
Microsoft Access MVP
Once the user has made a selection from the combobox called "Section"
I want this item to be entered into a table called "Infraction" in a
field called "Section".

The Financial Regulations Combobox is now called Acts and Regulations.

z

Joan Wild said:
One doesn't 'load a table' into a combobox, exactly.

Keep going. Suppose the second combo box listed all the records in
the CAPS table. Then what do you want to do?

Also, what happened to the Financial Regulations combobox?


--
Joan Wild
Microsoft Access MVP
I tend to do that.

The items in the Acts and Regulations box are loaded from a single
data table. Each item in the list refers to a seperate table. In
this case when the item CAPS is selected from the first combobox, I
would like to have the records in the table called CAPS to be
loaded into the second combobox called "Section".

I hope this is a little bit clearer.

Z

:

You've confused me now. Why are you trying to load a table.?

I thought you had a form with a combobox named [Acts and
Regulations] and a second named (actually I don't know what it's
named but it contains Financial Regulations). You want to make a
selection in the Acts and Regulations combobox, that then restricts
the list of values to select in the second combobox.

Please explain how the tblCAPS comes in to play.


--
Joan Wild
Microsoft Access MVP

Zoltar54 wrote:
Joan,

Thanks once again. The code no longer gives me an error, however
it will not load the data in the tbl CAPS. As I am quite new at
the VBA and Access world perhaps I am missing something. The item
called tblCAPS - this is the taable I want loaded when a
particular Item is selected from the first combobox. Does this
need to defined (Dim) and if so what do I define it as
(recordset, access object etc..)

Z

:

ssql = "SELECT sectionID, actregID, section, description From
tblCAPS WHERE actregID= " & me.ActReg & " ORDER BY
section,description"

You have misplaced '&' and quotes.


--
Joan Wild
Microsoft Access MVP

Zoltar54 wrote:
Joan,

Thnaks for the tip. I have entered the code (using the names of
my objects) and it does not seem to work. Below is the code.
Can you provide some further insight?

Z

Dim ssql As String

ssql = "SELECT sectionID, actregID, section, description" &
"From tblCAPS WHERE actregID=&me.ActReg" & "ORDER BY
section,description"

Me.Sect.RowSource = ssql

:

See
http://www.pacificdb.com.au/MVP/Code/ComboRS.htm

--
Joan Wild
Microsoft Access MVP

Zoltar54 wrote:
I am working with a databse that has 22 seperate tables. On
my form I have a combobox that is titled Acts and Regulations.
This combobox is populated with data from one table. When one
of the options is selected I would like to load a second
combobox with the corresponding date eg: when Financial
Tracking Regulations is selected I want the second combobox to
be populated by the table titled Financial Regulations.

Can someone help me with this?

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