Re: List Box default value shown
- From: "Ken Snell [MVP]" <kthsneisllis9@xxxxxxxxxxxxxxxxxx>
- Date: Wed, 12 Oct 2005 20:33:20 -0400
I think part of my confusion is because of terminologies.... a list box
doesn't have a dropdown list (shows when you click a "down" arrow) - that is
a combo box. Now I think I'm understanding what you want to do.
You want the "text box" portion of the combo box to be empty. This can be
done by setting the value of the combo box to Null.
The "trick" is to know when to do it. I assume that the combo boxes are
bound to fields in the form's Record Source table/query? When you want to
use the combo boxes, are you starting on a new record? If yes, and the combo
boxes are bound to fields, and those fields are empty, the textbox portion
of the combo box should automatically be empty.
If the combo box is not bound to a field, then you can use the form's
Current event to set the value of the combo box to Null. This could be done
only if you're starting a new record, or it can be done anytime you move
from one record to another.
Private Sub Form_Current()
'** This code assumes that the combo box is not
'** bound to a field in the form's RecordSource
' omit the If and End If lines if you want the combo box to be
' empty whenever you move from one record to another
If Me.NewRecord = True Then ' omit this line if...(see above)
Me.NameOfComboBox.Value = Null
End If ' omit this line if...(see above)
End Sub
--
Ken Snell
<MS ACCESS MVP>
"Damon" <Damon@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:9842C983-CDCF-4806-8BA9-A3F06416613F@xxxxxxxxxxxxxxxx
> OK, I have a form with some text boxes and some list boxes. The purpose of
> the form is to enter the personal information of a person who is entered
> into
> a personnel table. The text boxes are used to collect the person's name,
> age,
> nickname, etc...; items that I cannot predict. The list boxes allow me to
> choose things like rank, gender, etc.... THen I hit add record and my
> choices
> are entered into the table. After I hit enter all the fields should
> display
> as emtpy and in the case of the list boxes, when I click on the down arrow
> I
> should be presented with my choices.
>
> I hope that helps.
>
> Damon
>
> "Ken Snell [MVP]" wrote:
>
>> What "window" do you mean for the new record? I think you're referring to
>> some other controls on the form? Perhaps it would help if you describe
>> your
>> form's setup and the actions that you are doing. I'm just not "seeing"
>> your
>> setup in my mind.
>>
>> --
>>
>> Ken Snell
>> <MS ACCESS MVP>
>>
>> "Damon" <Damon@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>> news:825E56BB-906A-4A85-A12C-B8B5EEEC203E@xxxxxxxxxxxxxxxx
>> > Let me clarify, I want values in the list boxes so that I may choose
>> > from
>> > them, but I do not want any of the items showing up in the window upon
>> > starting a new record. I want to be presented with a form that has no
>> > data
>> > visible in the fields, but when I click on one of the listboxes I can
>> > select
>> > from a choice in the list. I want the default value shown on the form
>> > to
>> > be
>> > blank.
>> >
>> > "Ken Snell [MVP]" wrote:
>> >
>> >> I'm a bit confused. Your original post said you didn't want any values
>> >> to
>> >> be
>> >> in the listbox; only way to do that is to empty the Row Source. Is
>> >> that
>> >> what
>> >> you want to do?
>> >>
>> >> Regarding "basing one listbox on the value of another", see this
>> >> article
>> >> at
>> >> The ACCESS Web for an explanation of how it's done for combo boxes.
>> >> It'll
>> >> work for listboxes too.
>> >> http://www.mvps.org/access/forms/frm0028.htm
>> >>
>> >> --
>> >>
>> >> Ken Snell
>> >> <MS ACCESS MVP>
>> >>
>> >>
>> >> "Damon" <Damon@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>> >> news:7CC2F515-F59F-4881-830F-D36E4938DFAA@xxxxxxxxxxxxxxxx
>> >> > These are all list boxes as I have immutable data for each one and I
>> >> > do
>> >> > not
>> >> > want the ability to enter new data to exist. Click on a box, choose
>> >> > a
>> >> > value
>> >> > and you are done :-)
>> >> >
>> >> > Damon
>> >> >
>> >> > "Ken Snell [MVP]" wrote:
>> >> >
>> >> >> Are we talking of list boxes (which do not allow you to type in a
>> >> >> value),
>> >> >> or
>> >> >> a combo box (which does allow you to type in a value)?
>> >> >>
>> >> >> It sounds as if you mean combo boxes. In that case, just set the
>> >> >> .Value
>> >> >> property of the combo box to Null in the Current event if
>> >> >> Me.NewRecord
>> >> >> =
>> >> >> True.
>> >> >>
>> >> >> --
>> >> >>
>> >> >> Ken Snell
>> >> >> <MS ACCESS MVP>
>> >> >>
>> >> >> "Damon" <Damon@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>> >> >> news:13631DB3-CA4A-43D1-9758-2C90AFA811CC@xxxxxxxxxxxxxxxx
>> >> >> >I have 18 list boxes: 4 populate the boxes with values I typed in,
>> >> >> >the
>> >> >> >other
>> >> >> > 14 are populated from tables. the values I pick will, of course,
>> >> >> > be
>> >> >> > entered
>> >> >> > into the record.
>> >> >> >
>> >> >> > A second question that is related is I would like the list in one
>> >> >> > of
>> >> >> > the
>> >> >> > list boxes to be determined by the value of a previous box.
>> >> >> >
>> >> >> > thanks for the help and the quick reply,
>> >> >> > Damon
>> >> >> >
>> >> >> > "Ken Snell [MVP]" wrote:
>> >> >> >
>> >> >> >> I assume that the listbox is unbound... so set its Row Source
>> >> >> >> equal
>> >> >> >> to
>> >> >> >> ""
>> >> >> >> in
>> >> >> >> the form's Current event if Me.NewRecord = True.
>> >> >> >>
>> >> >> >> --
>> >> >> >>
>> >> >> >> Ken Snell
>> >> >> >> <MS ACCESS MVP>
>> >> >> >>
>> >> >> >> "Damon" <Damon@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>> >> >> >> news:F4FD1234-2CB2-467B-A2A2-08287338BBFE@xxxxxxxxxxxxxxxx
>> >> >> >> >I have some list boxes on my form and I would like it so that
>> >> >> >> >when
>> >> >> >> >the
>> >> >> >> >user
>> >> >> >> > runs the form there is no value in the list box window for a
>> >> >> >> > new
>> >> >> >> > record.
>> >> >> >> > Right now when i create a new record the list boxes retain the
>> >> >> >> > last
>> >> >> >> > value
>> >> >> >> > shown.
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>
>>
>>
>>
.
- References:
- Re: List Box default value shown
- From: Ken Snell [MVP]
- Re: List Box default value shown
- From: Ken Snell [MVP]
- Re: List Box default value shown
- From: Ken Snell [MVP]
- Re: List Box default value shown
- From: Damon
- Re: List Box default value shown
- Prev by Date: Re: Close form, skips calling form focus
- Next by Date: Re: Form Construction
- Previous by thread: Re: List Box default value shown
- Next by thread: Re: List Box default value shown
- Index(es):
Relevant Pages
|