473,327 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

textboxes updating from a listbox

I am trying to make a form in which i can view the ihe information for
companies. I have a combobox which contains all of the work
categories that the companies fit into. I have gotten the listbox to
show all of the companies that fit into a given category when it is
selected in the combobox. I now need the textboxes to display the
phone #, fax #, etc. for a company when i click on it in the listbox.
Thank you in advance for any help you can give me.
Nov 13 '05 #1
8 1639
Include the phone #, fax #, etc. in the rowsource of the listbox. Then put the
following code in the AfterUpdate event of the listbox:

Me!PhoneNumTextbox = Me!NameOfListbox.Column(phone# column in rowsource)\
Me!FaxNumTextbox = Me!NameOfListbox.Column(fax# column in rowsource)
etc

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com

"Andy Weinmann" <ar********@student.ysu.edu> wrote in message
news:b7**************************@posting.google.c om...
I am trying to make a form in which i can view the ihe information for
companies. I have a combobox which contains all of the work
categories that the companies fit into. I have gotten the listbox to
show all of the companies that fit into a given category when it is
selected in the combobox. I now need the textboxes to display the
phone #, fax #, etc. for a company when i click on it in the listbox.
Thank you in advance for any help you can give me.

Nov 13 '05 #2
I inserted the following code into the AfterUpdate event of my
listbox:

Me!txtPhone = Me!lstCompanies.Column(4)
Me!txtExt = Me!lstCompanies.Column(5)
Me!txtFax = Me!lstCompanies.Column(6)
Me!txtContact = Me!lstCompanies.Column(7)

I set the listbox to include all of the relevant information, in the
indicated columns. However, when I click a company, nothing changes
and I get no error message. I have an ID field that uniquely
identifies each company/work category match. Would I be better off
setting up an SQL statement for each of my textboxes, and then telling
them to requery in the AfterUpdate event of my listbox? If so, what
kind of an SQL statement would I need to write? Thank you in advance
for any help you can offer.

P.S. I know this is probably a very basic question, but I am just
starting in using Access and SQL.
Nov 13 '05 #3
On 1 Jul 2004 06:36:34 -0700, ar********@student.ysu.edu (Andy
Weinmann) wrote:
I inserted the following code into the AfterUpdate event of my
listbox:

Me!txtPhone = Me!lstCompanies.Column(4)
Me!txtExt = Me!lstCompanies.Column(5)
Me!txtFax = Me!lstCompanies.Column(6)
Me!txtContact = Me!lstCompanies.Column(7)

I set the listbox to include all of the relevant information, in the
indicated columns. However, when I click a company, nothing changes
and I get no error message. I have an ID field that uniquely
identifies each company/work category match. Would I be better off
setting up an SQL statement for each of my textboxes, and then telling
them to requery in the AfterUpdate event of my listbox? If so, what
kind of an SQL statement would I need to write? Thank you in advance
for any help you can offer.

P.S. I know this is probably a very basic question, but I am just
starting in using Access and SQL.

Andy, all you need to do is to set the Control Source of the various
text boxes to the particular column of the list box.

For example: In the Control Source of txtPhone put the following...
= [lstCompanies].[Column](4)

Note that the column index is zero based. So column 4 is the 5th
column.

The textboxes will refresh each time the list box is updated - no code
required.

Also to clear everything set the list box to null.
Me.lstCompanies = Null

- Jim
Nov 13 '05 #4
On 1 Jul 2004 06:36:34 -0700, ar********@student.ysu.edu (Andy
Weinmann) wrote:
I inserted the following code into the AfterUpdate event of my
listbox:

Me!txtPhone = Me!lstCompanies.Column(4)
Me!txtExt = Me!lstCompanies.Column(5)
Me!txtFax = Me!lstCompanies.Column(6)
Me!txtContact = Me!lstCompanies.Column(7)

I set the listbox to include all of the relevant information, in the
indicated columns. However, when I click a company, nothing changes
and I get no error message. I have an ID field that uniquely
identifies each company/work category match. Would I be better off
setting up an SQL statement for each of my textboxes, and then telling
them to requery in the AfterUpdate event of my listbox? If so, what
kind of an SQL statement would I need to write? Thank you in advance
for any help you can offer.

P.S. I know this is probably a very basic question, but I am just
starting in using Access and SQL.

Andy, all you need to do is to set the Control Source of the various
text boxes to the particular column of the list box.

For example: In the Control Source of txtPhone put the following...
= [lstCompanies].[Column](4)

Note that the column index is zero based. So column 4 is the 5th
column.

The textboxes will refresh each time the list box is updated - no code
required.

Also to clear everything set the list box to null.
Me.lstCompanies = Null

- Jim
Nov 13 '05 #5
On 1 Jul 2004 06:36:34 -0700, ar********@student.ysu.edu (Andy
Weinmann) wrote:
I inserted the following code into the AfterUpdate event of my
listbox:

Me!txtPhone = Me!lstCompanies.Column(4)
Me!txtExt = Me!lstCompanies.Column(5)
Me!txtFax = Me!lstCompanies.Column(6)
Me!txtContact = Me!lstCompanies.Column(7)

I set the listbox to include all of the relevant information, in the
indicated columns. However, when I click a company, nothing changes
and I get no error message. I have an ID field that uniquely
identifies each company/work category match. Would I be better off
setting up an SQL statement for each of my textboxes, and then telling
them to requery in the AfterUpdate event of my listbox? If so, what
kind of an SQL statement would I need to write? Thank you in advance
for any help you can offer.

P.S. I know this is probably a very basic question, but I am just
starting in using Access and SQL.

Andy, all you need to do is to set the Control Source of the various
text boxes to the particular column of the list box.

For example: In the Control Source of txtPhone put the following...
= [lstCompanies].[Column](4)

Note that the column index is zero based. So column 4 is the 5th
column.

The textboxes will refresh each time the list box is updated - no code
required.

Also to clear everything set the list box to null.
Me.lstCompanies = Null

- Jim
Nov 13 '05 #6
On Thu, 01 Jul 2004 14:18:48 GMT, Ji****@NOTdatacentricsolutions.com
(Jim Allensworth) wrote:
On 1 Jul 2004 06:36:34 -0700, ar********@student.ysu.edu (Andy
Weinmann) wrote:
I inserted the following code into the AfterUpdate event of my
listbox:

Me!txtPhone = Me!lstCompanies.Column(4)
Me!txtExt = Me!lstCompanies.Column(5)
Me!txtFax = Me!lstCompanies.Column(6)
Me!txtContact = Me!lstCompanies.Column(7)

I set the listbox to include all of the relevant information, in the
indicated columns. However, when I click a company, nothing changes
and I get no error message. I have an ID field that uniquely
identifies each company/work category match. Would I be better off
setting up an SQL statement for each of my textboxes, and then telling
them to requery in the AfterUpdate event of my listbox? If so, what
kind of an SQL statement would I need to write? Thank you in advance
for any help you can offer.

P.S. I know this is probably a very basic question, but I am just
starting in using Access and SQL.

Andy, all you need to do is to set the Control Source of the various
text boxes to the particular column of the list box.

For example: In the Control Source of txtPhone put the following...
= [lstCompanies].[Column](4)

Note that the column index is zero based. So column 4 is the 5th
column.

The textboxes will refresh each time the list box is updated - no code
required.

Also to clear everything set the list box to null.
Me.lstCompanies = Null


I just wanted to add: In the list box make sure you have the Column
Count property set. If you have 8 columns then it should be 8. In the
Column Width property set the widths as needed - setting any you don't
want to see to zero.

- Jim

P.S. Sorry about the multiple posts - my ISP was not cooperating with
my reader.
Nov 13 '05 #7
Thank You! That fixes my problem completely.
Nov 13 '05 #8
Ok. I have another problem along the same lines. I need to make form
through which I can edit the information for these same companies. I
used the same form as for viewing the information, but it tells me the
form is read-only, even when i set the "locked" property for all of my
textboxes to "no". What do I do? Is it because the textboxes are
reading from the listbox rather than the table? If so, what code do I
use to make the textboxes from the table where the ID equals that of
the company selected in the listbox?

TIA,
Andy
Nov 13 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Andy Weinmann | last post by:
I need to make a form through which I can edit the information for companies. I used a form in which the textboxes read from different columns from a listbox to display the information for a...
3
by: gdbjohnson-AT-yahoo-dot-ca-nospamplz | last post by:
I have a ListBox built of a simple custom object for the ListItems used to be able to hold a Data Value, and a Display Value, with accessors for each. I have overridden the ToString method to...
1
by: MrNobody | last post by:
Hi, I'm doing something where I add custom objects to a ListBox which have aToString() method overriden so it displays what I want. When adding instances of these custom objects to the ListBox I...
2
by: Jason | last post by:
I want to loop through all textbox controls to determine their .text value. If the .text value is not "" then display the textbox. I have tried the following with no luck. Any help would be...
1
by: Spock | last post by:
Hi. I have a form with a listbox and a few label fields all bound to a dataset. When i navigate the listbox the labels change accordingly. so far everything works good. I made a button to...
6
by: Zytan | last post by:
In win32 there was a way to 'turn off' a listbox from updating until you were done adding elements. Is there a way to do this in .NET? Zytan
6
by: =?Utf-8?B?S2Fp?= | last post by:
Hi all, using AJAX Toolkit with vb.net 2.0 how could I make this "Updating..." Screen like e.g. on Codeplex when you click on the "Vote" button...
2
by: julie18881 | last post by:
I may be being really stupid here, i have spent the last 3 hours looking round your site and some other for answers to my problem, but have not had much luck (possibly cuase my brain just isn't...
3
by: Reg Verrin | last post by:
I have a program that displays constantly changing prices which it sources from the web once per second. The prices are displayed on a Listbox (not the best choice but there are good reasons for...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.