Field Options and Combo Lists?

M

Mike

Wondering if anyone knows how to make this work. I have two fields in a
form, both Combo Boxes. I want the Value List in the first box to determine
what the Value List in the second box will be. For example, if the first box
is all State Names, if you select California, the second box provides all of
the City names for that state. However, if you change the first box to Utah,
the second box provides all the City names for Utah.
 
L

Lance

In the afterupdate event of the states combobox write code to adjust the
rowsource of the city combobox. Something like:

Me.combo_STATE.RowSource = "SELECT * FROM city_table WHERE [state] = '" &
Me.combo_City.Value & "'"
Me.combo_City.Requery
 
P

p2p

I'm facing a similar problem, but having trouble translating the syntax.
I've got two tables, one called Trades, with ClientID and MeetingDate fields.
I've got another table called Meetings with ClientID and MeetingDate fields.
When I enter a ClientID in the Trades table, I'd like to update the
RowSource for the MeetingID field in the Trades table with MeetingDates from
the Meetings table that have the same ClientID.

The best I've been able to come up with is this:

Me.MeetingDate.RowSource = "SELECT [MeetingDate] FROM Meetings WHERE
[ClientID] = '" & _ Me.MeetingDate.Value & "'"
Me.MeetingDate.Requery

But, it isn't working. No MeetingDates show up in the combo box. Any help
would be greatly appreciated. Thanks.

Brad

Lance said:
In the afterupdate event of the states combobox write code to adjust the
rowsource of the city combobox. Something like:

Me.combo_STATE.RowSource = "SELECT * FROM city_table WHERE [state] = '" &
Me.combo_City.Value & "'"
Me.combo_City.Requery

Mike said:
Wondering if anyone knows how to make this work. I have two fields in a
form, both Combo Boxes. I want the Value List in the first box to determine
what the Value List in the second box will be. For example, if the first box
is all State Names, if you select California, the second box provides all of
the City names for that state. However, if you change the first box to Utah,
the second box provides all the City names for Utah.
 
L

Lance

Does the bound column of your combobox contain the meeting date?

p2p said:
I'm facing a similar problem, but having trouble translating the syntax.
I've got two tables, one called Trades, with ClientID and MeetingDate fields.
I've got another table called Meetings with ClientID and MeetingDate fields.
When I enter a ClientID in the Trades table, I'd like to update the
RowSource for the MeetingID field in the Trades table with MeetingDates from
the Meetings table that have the same ClientID.

The best I've been able to come up with is this:

Me.MeetingDate.RowSource = "SELECT [MeetingDate] FROM Meetings WHERE
[ClientID] = '" & _ Me.MeetingDate.Value & "'"
Me.MeetingDate.Requery

But, it isn't working. No MeetingDates show up in the combo box. Any help
would be greatly appreciated. Thanks.

Brad

Lance said:
In the afterupdate event of the states combobox write code to adjust the
rowsource of the city combobox. Something like:

Me.combo_STATE.RowSource = "SELECT * FROM city_table WHERE [state] = '" &
Me.combo_City.Value & "'"
Me.combo_City.Requery

Mike said:
Wondering if anyone knows how to make this work. I have two fields in a
form, both Combo Boxes. I want the Value List in the first box to determine
what the Value List in the second box will be. For example, if the first box
is all State Names, if you select California, the second box provides all of
the City names for that state. However, if you change the first box to Utah,
the second box provides all the City names for Utah.
 
P

p2p

All of the comboboxes are bound, and the MeetingDate fields in each form
contain meeting dates.

Lance said:
Does the bound column of your combobox contain the meeting date?

p2p said:
I'm facing a similar problem, but having trouble translating the syntax.
I've got two tables, one called Trades, with ClientID and MeetingDate fields.
I've got another table called Meetings with ClientID and MeetingDate fields.
When I enter a ClientID in the Trades table, I'd like to update the
RowSource for the MeetingID field in the Trades table with MeetingDates from
the Meetings table that have the same ClientID.

The best I've been able to come up with is this:

Me.MeetingDate.RowSource = "SELECT [MeetingDate] FROM Meetings WHERE
[ClientID] = '" & _ Me.MeetingDate.Value & "'"
Me.MeetingDate.Requery

But, it isn't working. No MeetingDates show up in the combo box. Any help
would be greatly appreciated. Thanks.

Brad

Lance said:
In the afterupdate event of the states combobox write code to adjust the
rowsource of the city combobox. Something like:

Me.combo_STATE.RowSource = "SELECT * FROM city_table WHERE [state] = '" &
Me.combo_City.Value & "'"
Me.combo_City.Requery

:

Wondering if anyone knows how to make this work. I have two fields in a
form, both Combo Boxes. I want the Value List in the first box to determine
what the Value List in the second box will be. For example, if the first box
is all State Names, if you select California, the second box provides all of
the City names for that state. However, if you change the first box to Utah,
the second box provides all the City names for Utah.
 
L

Lance

Actually I just noticed something, I read it wrong the first time.

You need to make sure the bound column of your meetingdate combo contains
the field related to clientID. if you replace your below code with just a
"msgbox me.MeetingDate.Value" what do you get?

p2p said:
All of the comboboxes are bound, and the MeetingDate fields in each form
contain meeting dates.

Lance said:
Does the bound column of your combobox contain the meeting date?

p2p said:
I'm facing a similar problem, but having trouble translating the syntax.
I've got two tables, one called Trades, with ClientID and MeetingDate fields.
I've got another table called Meetings with ClientID and MeetingDate fields.
When I enter a ClientID in the Trades table, I'd like to update the
RowSource for the MeetingID field in the Trades table with MeetingDates from
the Meetings table that have the same ClientID.

The best I've been able to come up with is this:

Me.MeetingDate.RowSource = "SELECT [MeetingDate] FROM Meetings WHERE
[ClientID] = '" & _ Me.MeetingDate.Value & "'"
Me.MeetingDate.Requery

But, it isn't working. No MeetingDates show up in the combo box. Any help
would be greatly appreciated. Thanks.

Brad

:

In the afterupdate event of the states combobox write code to adjust the
rowsource of the city combobox. Something like:

Me.combo_STATE.RowSource = "SELECT * FROM city_table WHERE [state] = '" &
Me.combo_City.Value & "'"
Me.combo_City.Requery

:

Wondering if anyone knows how to make this work. I have two fields in a
form, both Combo Boxes. I want the Value List in the first box to determine
what the Value List in the second box will be. For example, if the first box
is all State Names, if you select California, the second box provides all of
the City names for that state. However, if you change the first box to Utah,
the second box provides all the City names for Utah.
 
P

p2p

I guess I'm in over my head here. I didn't realize how involved this was
going to be before I started. In any event, I appreciate your help.

I don't know what you mean by: "You need to make sure the bound column of
your meetingdate combo contains the field related to clientID." In the Bound
Column field of the Property Sheet for the MeetingDate combobox, it says 1.
Should I change it to show the ClientID of the Meetings table? If so, how
can I do this?

Given that, changing the VBA code for the ClientID combobox on the Trades
form to the code you provided below gives a runtime error.

Lance said:
Actually I just noticed something, I read it wrong the first time.

You need to make sure the bound column of your meetingdate combo contains
the field related to clientID. if you replace your below code with just a
"msgbox me.MeetingDate.Value" what do you get?

p2p said:
All of the comboboxes are bound, and the MeetingDate fields in each form
contain meeting dates.

Lance said:
Does the bound column of your combobox contain the meeting date?

:

I'm facing a similar problem, but having trouble translating the syntax.
I've got two tables, one called Trades, with ClientID and MeetingDate fields.
I've got another table called Meetings with ClientID and MeetingDate fields.
When I enter a ClientID in the Trades table, I'd like to update the
RowSource for the MeetingID field in the Trades table with MeetingDates from
the Meetings table that have the same ClientID.

The best I've been able to come up with is this:

Me.MeetingDate.RowSource = "SELECT [MeetingDate] FROM Meetings WHERE
[ClientID] = '" & _ Me.MeetingDate.Value & "'"
Me.MeetingDate.Requery

But, it isn't working. No MeetingDates show up in the combo box. Any help
would be greatly appreciated. Thanks.

Brad

:

In the afterupdate event of the states combobox write code to adjust the
rowsource of the city combobox. Something like:

Me.combo_STATE.RowSource = "SELECT * FROM city_table WHERE [state] = '" &
Me.combo_City.Value & "'"
Me.combo_City.Requery

:

Wondering if anyone knows how to make this work. I have two fields in a
form, both Combo Boxes. I want the Value List in the first box to determine
what the Value List in the second box will be. For example, if the first box
is all State Names, if you select California, the second box provides all of
the City names for that state. However, if you change the first box to Utah,
the second box provides all the City names for Utah.
 
L

Lance

Essentially when you reference the value of a combobox you are getting the
value of ONE of the included columns in that combobox. You pick which column
to return via the bound column property.

For example, you make a combobox with the columns ( AKA fields ): [First
Name],[Middle Name] and [Last Name]. If your bound column is set to 1,
accessing the value of the combobox will return the first name. But, if you
set the bound column to 2 it will return the middle name, and 3 will return
the last name.

What I'm guessing is happening to you is that the bound column of your
combobox is pointing to a date field, thus when you create your sql statement
you're comparing your client ID to a date.. which will never match.

If you right click on the combo box and select properties you should be able
to see the row source and bound column properties in the data section. Click
the ellipse button [...] and make sure the field you want to display is equal
to the bound column number.

If you need help, just past a copy of the row source property here and I'll
see what I can do.

p2p said:
I guess I'm in over my head here. I didn't realize how involved this was
going to be before I started. In any event, I appreciate your help.

I don't know what you mean by: "You need to make sure the bound column of
your meetingdate combo contains the field related to clientID." In the Bound
Column field of the Property Sheet for the MeetingDate combobox, it says 1.
Should I change it to show the ClientID of the Meetings table? If so, how
can I do this?

Given that, changing the VBA code for the ClientID combobox on the Trades
form to the code you provided below gives a runtime error.

Lance said:
Actually I just noticed something, I read it wrong the first time.

You need to make sure the bound column of your meetingdate combo contains
the field related to clientID. if you replace your below code with just a
"msgbox me.MeetingDate.Value" what do you get?

p2p said:
All of the comboboxes are bound, and the MeetingDate fields in each form
contain meeting dates.

:

Does the bound column of your combobox contain the meeting date?

:

I'm facing a similar problem, but having trouble translating the syntax.
I've got two tables, one called Trades, with ClientID and MeetingDate fields.
I've got another table called Meetings with ClientID and MeetingDate fields.
When I enter a ClientID in the Trades table, I'd like to update the
RowSource for the MeetingID field in the Trades table with MeetingDates from
the Meetings table that have the same ClientID.

The best I've been able to come up with is this:

Me.MeetingDate.RowSource = "SELECT [MeetingDate] FROM Meetings WHERE
[ClientID] = '" & _ Me.MeetingDate.Value & "'"
Me.MeetingDate.Requery

But, it isn't working. No MeetingDates show up in the combo box. Any help
would be greatly appreciated. Thanks.

Brad

:

In the afterupdate event of the states combobox write code to adjust the
rowsource of the city combobox. Something like:

Me.combo_STATE.RowSource = "SELECT * FROM city_table WHERE [state] = '" &
Me.combo_City.Value & "'"
Me.combo_City.Requery

:

Wondering if anyone knows how to make this work. I have two fields in a
form, both Combo Boxes. I want the Value List in the first box to determine
what the Value List in the second box will be. For example, if the first box
is all State Names, if you select California, the second box provides all of
the City names for that state. However, if you change the first box to Utah,
the second box provides all the City names for Utah.
 

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