Get ListBox Item into a Textbox

C

Chris

Hello,

I am having troubles with a listbox and a textbox.

My Listbox is populated with StoreID (hidden), StoreName, StoreType

I want to get the StoreID into a textbox. All my methods return Error.

TIA
Chris
 
D

Duane Hookom

Try a control source of:
=lboYourLBName.Column(0)
Typically the StoreID is the bound column so all you would need is:
=lboYourLBName
 
C

Chris

Thanks, but it still is not working the way I had hoped. Here is more info.

I have a listbox that has StoreID, StoreName, etc

I want the user to click on the store he wants, and then fill in data into
fields lower in the form. My problem is when he clicks the name, and then
fills in the data below, the table is populated, but the StoreID is blank.
I wanted to 'throw' the storeID into hidden textbox, so that when the line
updates, the storeid also goes into the table.

Unless there is a better way to do it. Oh, and also, my listbox is
filtered.

Chris
 
D

Duane Hookom

So apparently the text box is bound to a field in a table. If so, use code in
the after update event of the list box
Me.txtStoreID = lboYourLBName.Column(0)

I'm not sure why you don't use a bound list box or combo box.
 
C

Chris

I didn't use a bound list or combo box because I didn't want the user to
have to select the store twice.

Me.tbStore = lbStore.Column(0) give me the following error:

The value you entered isn't valid for this field
 
C

Chris

I must have missed a step. I walked through it again and it seems to work.
But now my problem is, that it changes the top line item in my continuous
form. It also updates the last item (which is what I want)
 
C

Chris

I don't really know the terminology of access yet, but I will give it a try.

When I click on a Store in my listbox, it filters the bottom part of my form
(which is set as continuous). So, say I click on StoreA. The lower part of
my form lists 10 line items. Now I click on StoreB. The top line item that
was display for StoreA, has now changed to StoreB. All the rest are the
correct. Then I click on StoreC. the top line item changes to StoreC and
the rest are fine.

As I look deeper into it. It is not always the top line item. It changes
whichever item has the black triangle beside it. So, I guess I have to make
sure the last item is selected before I click on a different Store. If I
use acLast, it selects the last item and then changes it. If I create a new
item, then everytime I click a name a new item is created, which adds tons
of blank entries into my DB.. Is there a command to select 'that row which
is blank at the bottom of my form'?

Thank you,
Chris
 
D

Duane Hookom

It sounds like your form is messed up. If you want to find or filter your
continuous form records based on the list box selection, your list box should
not have a control source.
 
C

Chad Cameron

My listbox is unbound. But I do have it updating a bound textbox in the
continuous part of my form. In doing so, it changes the line item that has
the black arrow and also my very last line (which all the fields are blank
[except the textbox of course]) I guess I need a way to update only the
verylast textbox in the continuous form part.
 
D

Duane Hookom

What you are doing is very un-orthodox. I'm not sure where you picked up the
method.
--
Duane Hookom
Microsoft Access MVP


Chad Cameron said:
My listbox is unbound. But I do have it updating a bound textbox in the
continuous part of my form. In doing so, it changes the line item that has
the black arrow and also my very last line (which all the fields are blank
[except the textbox of course]) I guess I need a way to update only the
verylast textbox in the continuous form part.
 
C

Chad Cameron

I guess that is what happens with zero training and trying to help someone
else out. I have just enough knowledge to get me in trouble.

I guess I need to increase my base knowledge. If I have a form, with a
bunch of fields, it makes sense to me that I can just enter data into the
fields and it will go my my table. But, how do I go about getting data into
a table when I don't have a field on my form.

For instance.
1. Say all the stores that are being enter into my DB are Shoe Stores. I
don't want to enter Shoe Stores into the StoreType for every line item in
my continuous form. How can I make the form just put it there.
2. Lets go one step further. My DB has expanded. Now I can have Shoe
Stores & Hat Stores. I want to be able to select one or the other from a
listbox. How do I get the selected item in the listbox into my table via
the form.

The more I think this through and talk about it, the more I see that this DB
I have taken over is going to end up looking like my other DB that I have
been having so much trouble with. I am sorry but I think I might be walking
away from this and my other project.

The amount of time I have spent on it, it would have been cheaper to hire
someone to do it right.

Duane Hookom said:
What you are doing is very un-orthodox. I'm not sure where you picked up
the
method.
--
Duane Hookom
Microsoft Access MVP


Chad Cameron said:
My listbox is unbound. But I do have it updating a bound textbox in the
continuous part of my form. In doing so, it changes the line item that
has
the black arrow and also my very last line (which all the fields are
blank
[except the textbox of course]) I guess I need a way to update only the
verylast textbox in the continuous form part.

Duane Hookom said:
It sounds like your form is messed up. If you want to find or filter
your
continuous form records based on the list box selection, your list box
should
not have a control source.

--
Duane Hookom
Microsoft Access MVP


:

I don't really know the terminology of access yet, but I will give it
a
try.

When I click on a Store in my listbox, it filters the bottom part of
my
form
(which is set as continuous). So, say I click on StoreA. The lower
part
of
my form lists 10 line items. Now I click on StoreB. The top line item
that
was display for StoreA, has now changed to StoreB. All the rest are
the
correct. Then I click on StoreC. the top line item changes to StoreC
and
the rest are fine.

As I look deeper into it. It is not always the top line item. It
changes
whichever item has the black triangle beside it. So, I guess I have
to
make
sure the last item is selected before I click on a different Store.
If I
use acLast, it selects the last item and then changes it. If I create
a
new
item, then everytime I click a name a new item is created, which adds
tons
of blank entries into my DB.. Is there a command to select 'that row
which
is blank at the bottom of my form'?

Thank you,
Chris


I don't understand "it changes the top line item in my continuous
form"
--
Duane Hookom
Microsoft Access MVP


:

I must have missed a step. I walked through it again and it seems
to
work.
But now my problem is, that it changes the top line item in my
continuous
form. It also updates the last item (which is what I want)

"Chris" <blank> wrote in message
I didn't use a bound list or combo box because I didn't want the
user
to
have to select the store twice.

Me.tbStore = lbStore.Column(0) give me the following error:

The value you entered isn't valid for this field

So apparently the text box is bound to a field in a table. If
so,
use
code in
the after update event of the list box
Me.txtStoreID = lboYourLBName.Column(0)

I'm not sure why you don't use a bound list box or combo box.

--

Duane Hookom
Microsoft Access MVP


:

Thanks, but it still is not working the way I had hoped. Here
is
more
info.

I have a listbox that has StoreID, StoreName, etc

I want the user to click on the store he wants, and then fill
in
data
into
fields lower in the form. My problem is when he clicks the
name,
and
then
fills in the data below, the table is populated, but the
StoreID
is
blank.
I wanted to 'throw' the storeID into hidden textbox, so that
when
the
line
updates, the storeid also goes into the table.

Unless there is a better way to do it. Oh, and also, my
listbox
is
filtered.

Chris

message
Of course, that assumes that the list box doesn't allow
MultiSelect.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


message
Try a control source of:
=lboYourLBName.Column(0)
Typically the StoreID is the bound column so all you would
need
is:
=lboYourLBName

--
Duane Hookom
Microsoft Access MVP


:

Hello,

I am having troubles with a listbox and a textbox.

My Listbox is populated with StoreID (hidden), StoreName,
StoreType

I want to get the StoreID into a textbox. All my methods
return
Error.

TIA
Chris
 
D

Duane Hookom

To update multiple records at one time, you generally use an update query. If
you are storing multiple store types for a single store, you should have a
table with one record per store, one table with one record per type, and one
table with a record for every combination of stores and types.

--
Duane Hookom
Microsoft Access MVP


Chad Cameron said:
I guess that is what happens with zero training and trying to help someone
else out. I have just enough knowledge to get me in trouble.

I guess I need to increase my base knowledge. If I have a form, with a
bunch of fields, it makes sense to me that I can just enter data into the
fields and it will go my my table. But, how do I go about getting data into
a table when I don't have a field on my form.

For instance.
1. Say all the stores that are being enter into my DB are Shoe Stores. I
don't want to enter Shoe Stores into the StoreType for every line item in
my continuous form. How can I make the form just put it there.
2. Lets go one step further. My DB has expanded. Now I can have Shoe
Stores & Hat Stores. I want to be able to select one or the other from a
listbox. How do I get the selected item in the listbox into my table via
the form.

The more I think this through and talk about it, the more I see that this DB
I have taken over is going to end up looking like my other DB that I have
been having so much trouble with. I am sorry but I think I might be walking
away from this and my other project.

The amount of time I have spent on it, it would have been cheaper to hire
someone to do it right.

Duane Hookom said:
What you are doing is very un-orthodox. I'm not sure where you picked up
the
method.
--
Duane Hookom
Microsoft Access MVP


Chad Cameron said:
My listbox is unbound. But I do have it updating a bound textbox in the
continuous part of my form. In doing so, it changes the line item that
has
the black arrow and also my very last line (which all the fields are
blank
[except the textbox of course]) I guess I need a way to update only the
verylast textbox in the continuous form part.

It sounds like your form is messed up. If you want to find or filter
your
continuous form records based on the list box selection, your list box
should
not have a control source.

--
Duane Hookom
Microsoft Access MVP


:

I don't really know the terminology of access yet, but I will give it
a
try.

When I click on a Store in my listbox, it filters the bottom part of
my
form
(which is set as continuous). So, say I click on StoreA. The lower
part
of
my form lists 10 line items. Now I click on StoreB. The top line item
that
was display for StoreA, has now changed to StoreB. All the rest are
the
correct. Then I click on StoreC. the top line item changes to StoreC
and
the rest are fine.

As I look deeper into it. It is not always the top line item. It
changes
whichever item has the black triangle beside it. So, I guess I have
to
make
sure the last item is selected before I click on a different Store.
If I
use acLast, it selects the last item and then changes it. If I create
a
new
item, then everytime I click a name a new item is created, which adds
tons
of blank entries into my DB.. Is there a command to select 'that row
which
is blank at the bottom of my form'?

Thank you,
Chris


I don't understand "it changes the top line item in my continuous
form"
--
Duane Hookom
Microsoft Access MVP


:

I must have missed a step. I walked through it again and it seems
to
work.
But now my problem is, that it changes the top line item in my
continuous
form. It also updates the last item (which is what I want)

"Chris" <blank> wrote in message
I didn't use a bound list or combo box because I didn't want the
user
to
have to select the store twice.

Me.tbStore = lbStore.Column(0) give me the following error:

The value you entered isn't valid for this field

So apparently the text box is bound to a field in a table. If
so,
use
code in
the after update event of the list box
Me.txtStoreID = lboYourLBName.Column(0)

I'm not sure why you don't use a bound list box or combo box.

--

Duane Hookom
Microsoft Access MVP


:

Thanks, but it still is not working the way I had hoped. Here
is
more
info.

I have a listbox that has StoreID, StoreName, etc

I want the user to click on the store he wants, and then fill
in
data
into
fields lower in the form. My problem is when he clicks the
name,
and
then
fills in the data below, the table is populated, but the
StoreID
is
blank.
I wanted to 'throw' the storeID into hidden textbox, so that
when
the
line
updates, the storeid also goes into the table.

Unless there is a better way to do it. Oh, and also, my
listbox
is
filtered.

Chris

message
Of course, that assumes that the list box doesn't allow
MultiSelect.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


message
Try a control source of:
=lboYourLBName.Column(0)
Typically the StoreID is the bound column so all you would
need
is:
=lboYourLBName

--
Duane Hookom
Microsoft Access MVP


:

Hello,

I am having troubles with a listbox and a textbox.

My Listbox is populated with StoreID (hidden), StoreName,
StoreType

I want to get the StoreID into a textbox. All my methods
return
Error.

TIA
Chris
 

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