By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,247 Members | 1,427 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,247 IT Pros & Developers. It's quick & easy.

Form drop down box options

P: n/a
I have a form that displays a dropdown box. The options in the drop down
vary according to a value queried from a database boolean (Yes/No) field. I
would like to do the following:

If the boolean value is True, then the dropdown options will be option1 and
option2.

If the boolean value is False, then the dropdown box will contain: option1,
option2 and option3.

That's it. The value of the boolean field will determine if the form
dropdown box contains either two or three options.

I have created the query which works fine. Unfortunately, I cannot figure
out how to populate the dropdown options according to the boolean value (True
or False) that is retrieved in the query

Cannot anyone help me out? Thanks

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200710/1

Oct 10 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Oct 10, 8:22 am, "dufnobles via AccessMonster.com" <u37896@uwe>
wrote:
I have a form that displays a dropdown box. The options in the drop down
vary according to a value queried from a database boolean (Yes/No) field. I
would like to do the following:

If the boolean value is True, then the dropdown options will be option1 and
option2.

If the boolean value is False, then the dropdown box will contain: option1,
option2 and option3.

That's it. The value of the boolean field will determine if the form
dropdown box contains either two or three options.

I have created the query which works fine. Unfortunately, I cannot figure
out how to populate the dropdown options according to the boolean value (True
or False) that is retrieved in the query

Cannot anyone help me out? Thanks

--
Message posted via AccessMonster.comhttp://www.accessmonster.com/Uwe/Forums.aspx/databases-ms-access/2007...
So, is there just one record in the query? Or is the boolean value
the same in all records? Or does the user select one of the records
before clicking on the combo box? Combo boxes can take a SQL string
as a rowsource. Are the options part of a table, or are they
hardwired? Combo boxes can take a literal string or a recordset as
the rowsource; just change the RowSourceType to the one you want.

Oct 10 '07 #2

P: n/a
Thanks OldPro,

I think I'm beginning to understand.

My query returns several records, each record has the boolean field which is
either 'Yes' or 'No' ( as well as several other fields as well).

Right now, the combo boxe options for each record are hard coded on the
form for just two options (this is obviously wrong). The third option never
shows up.

I think I need a rowSource to populate the box instead, as you suggested.
Right now, all information comes from a simple query: 'Select * from tableX'.
How would I go about creating this separate rowSource that you spoke of to
fill the combo box based on the True or False value stored in the tableX
query. Should this be another query, should I create another table or should
I make my original query more complicated?

I am very new at this,what is the easiest solution. Thanks so much for your
patience.
OldPro wrote:
>On Oct 10, 8:22 am, "dufnobles via AccessMonster.com" <u37896@uwe>
wrote:
>I have a form that displays a dropdown box. The options in the drop down
vary according to a value queried from a database boolean (Yes/No) field. I
[quoted text clipped - 17 lines]
>--
Message posted via AccessMonster.comhttp://www.accessmonster.com/Uwe/Forums.aspx/databases-ms-access/2007...

So, is there just one record in the query? Or is the boolean value
the same in all records? Or does the user select one of the records
before clicking on the combo box? Combo boxes can take a SQL string
as a rowsource. Are the options part of a table, or are they
hardwired? Combo boxes can take a literal string or a recordset as
the rowsource; just change the RowSourceType to the one you want.
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200710/1

Oct 10 '07 #3

P: n/a
On Oct 10, 9:37 am, "dufnobles via AccessMonster.com" <u37896@uwe>
wrote:
Thanks OldPro,

I think I'm beginning to understand.

My query returns several records, each record has the boolean field which is
either 'Yes' or 'No' ( as well as several other fields as well).

Right now, the combo boxe options for each record are hard coded on the
form for just two options (this is obviously wrong). The third option never
shows up.

I think I need a rowSource to populate the box instead, as you suggested.
Right now, all information comes from a simple query: 'Select * from tableX'.

How would I go about creating this separate rowSource that you spoke of to
fill the combo box based on the True or False value stored in the tableX
query. Should this be another query, should I create another table or should
I make my original query more complicated?

I am very new at this,what is the easiest solution. Thanks so much for your
patience.

OldPro wrote:
On Oct 10, 8:22 am, "dufnobles via AccessMonster.com" <u37896@uwe>
wrote:
I have a form that displays a dropdown box. The options in the drop down
vary according to a value queried from a database boolean (Yes/No) field. I
[quoted text clipped - 17 lines]
--
Message posted via AccessMonster.comhttp://www.accessmonster.com/Uwe/Forums.aspx/databases-ms-access/2007...
So, is there just one record in the query? Or is the boolean value
the same in all records? Or does the user select one of the records
before clicking on the combo box? Combo boxes can take a SQL string
as a rowsource. Are the options part of a table, or are they
hardwired? Combo boxes can take a literal string or a recordset as
the rowsource; just change the RowSourceType to the one you want.

--
Message posted via AccessMonster.comhttp://www.accessmonster.com/Uwe/Forums.aspx/databases-ms-access/2007...
I still need to know which record determines whether the combo box has
two or three items. It can still be hard coded, that's probably the
easiest way with only two or three items. Does the user select one of
the records before clicking on the combo box? If so, then put code in
the after update event of the control where the user selects the
record.
If userSelectsA then
cmbOptions.RowSource="Option One,Option Two,Option Three"
else
cmbOptions.RowSource="Option One,Option Two"
endif
Oct 11 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.