How to Populate Text Boxes with Values selected from a Combo Box

N

Nasir Khan

Hello Group

I tried to search this problem in the newsgroup but failed (due to my very
limited knowledge).

I have used the template of Access 2002 and created the Order Entry
database.

I changed the CompanyName text box to a combo box on the "Orders by
Customer" form and set its RowSource to show the company names in Ascending
order and it works fine. My problem is that if I select any company from
the combo box.. the related records.. for eg. CustomerID, FirstName,
LastName, Billing Address.etc etc ..... in other words all the other field
does not change to reflect the record selected for the CompanyName selected
in the Combo Box!

I looked in the newsgroup under the heading "Populate Text Boxes with
selection of Combo Box" and followed the solution mentioned there.. but
still it does not work.. I dont know what I am doing wrong... the thread
says to do something like follows:
=[cboName].[Column](0)
=[cboName].[Column](1)
=[cboName].[Column](2)
and so on................


but when I click on the combo box the CustomerID and Billing Address and
other field goes Blank...
How can I achieve this ?
I hope I have made myself clear.

Also I tried to get the "combobox wizard" started but did not succeed.. Is
it required to be installed as an Add In? How can I see the combobox wizard
to work on a form??

I would appreaciate any help in this matter.
 
K

Kevin Sprinkel

Hello, Nasir.

Your approach is OK, provided you're not trying to *store*
these other fields in the form's underlying table. The
Company ID fully defines the record, there is no need to
store the other fields in the Orders table. So I'll
assume for now that you just wish to *display* the other
Company fields. In order to use the Column method on your
combo box, you must include all the fields of interest in
the Row Source of the combo box. Let's say you include the
following fields:

CompanyID
CompanyName
Address
City
State
Zip

in a combo box named cboCompany. Column is zero-based, so
to refer to CompanyName, you would use cboCompany.Column
(1).

This can be done most easily with the wizard. There is a
toggle button on the Toolbox toolbar. It looks like a
wizard's wand and several stars. Choose View, Toolbox if
this toolbar is not active. Once the wizard is toggled
on, it will invoke automatically when you attempt to place
a new combo box.

If you're new to combo boxes, most developers generally
hide the primary key field, such that the combo box
displays the second row (index=1), in the example above,
CompanyName, yet the primary key value is what is actually
stored in the form's underlying table. This behavior is
controlled by the controls' Bound Column and Column Widths
properties. The wizard will set them for you, but to hide
the first column manually, set its width to 0".

HTH
Kevin Sprinkel
-----Original Message-----
Hello Group

I tried to search this problem in the newsgroup but failed (due to my very
limited knowledge).

I have used the template of Access 2002 and created the Order Entry
database.

I changed the CompanyName text box to a combo box on the "Orders by
Customer" form and set its RowSource to show the company names in Ascending
order and it works fine. My problem is that if I select any company from
the combo box.. the related records.. for eg. CustomerID, FirstName,
LastName, Billing Address.etc etc ..... in other words all the other field
does not change to reflect the record selected for the CompanyName selected
in the Combo Box!

I looked in the newsgroup under the heading "Populate Text Boxes with
selection of Combo Box" and followed the solution mentioned there.. but
still it does not work.. I dont know what I am doing wrong... the thread
says to do something like follows:
=[cboName].[Column](0)
=[cboName].[Column](1)
=[cboName].[Column](2)
and so on................


but when I click on the combo box the CustomerID and Billing Address and
other field goes Blank...
How can I achieve this ?
I hope I have made myself clear.

Also I tried to get the "combobox wizard" started but did not succeed.. Is
it required to be installed as an Add In? How can I see the combobox wizard
to work on a form??

I would appreaciate any help in this matter.



.
 
G

GSteven

Pardon me jumping in but...

This thread caught my eye because I was trying to do the same thing and
evidently don't have it right yet.

OK, I have a single table called cust (example). There are 4 fields; name,
addr1, phone and city. I create a combo box on my form called 'cust_name'
with the following (relevant, I think) properties;

Format:Column Count = 4
Data:Control Source = "" (nul or no value)
Input mask = ""
Row Source Type = "Table/Query"
Row Source = "select cust.name, cust.addr1, cust.phone, cust.city from
cust"
Bound Column = 1
Event:none set

This gives me a drop down menu from which I can select any one of my
customers. (this is good) In this drop down I can also see the other 3
fields that are identified in the query. (this is not good)

What I want to do is add the 3 other fields (text boxes) to my form in
random locations (to fit a pre-printed form) to show the other 3 values that
are related to the record that is chosen from the combo-box.

Try as I might I can't seem to make this happen. I'm guessing what I'm doing
is slightly different than the explanation given to Nasir because of the
random locations.

Any help will be appreciated.
Steve

Kevin Sprinkel said:
Hello, Nasir.

Your approach is OK, provided you're not trying to *store*
these other fields in the form's underlying table. The
Company ID fully defines the record, there is no need to
store the other fields in the Orders table. So I'll
assume for now that you just wish to *display* the other
Company fields. In order to use the Column method on your
combo box, you must include all the fields of interest in
the Row Source of the combo box. Let's say you include the
following fields:

CompanyID
CompanyName
Address
City
State
Zip

in a combo box named cboCompany. Column is zero-based, so
to refer to CompanyName, you would use cboCompany.Column
(1).

This can be done most easily with the wizard. There is a
toggle button on the Toolbox toolbar. It looks like a
wizard's wand and several stars. Choose View, Toolbox if
this toolbar is not active. Once the wizard is toggled
on, it will invoke automatically when you attempt to place
a new combo box.

If you're new to combo boxes, most developers generally
hide the primary key field, such that the combo box
displays the second row (index=1), in the example above,
CompanyName, yet the primary key value is what is actually
stored in the form's underlying table. This behavior is
controlled by the controls' Bound Column and Column Widths
properties. The wizard will set them for you, but to hide
the first column manually, set its width to 0".

HTH
Kevin Sprinkel
-----Original Message-----
Hello Group

I tried to search this problem in the newsgroup but failed (due to my very
limited knowledge).

I have used the template of Access 2002 and created the Order Entry
database.

I changed the CompanyName text box to a combo box on the "Orders by
Customer" form and set its RowSource to show the company names in Ascending
order and it works fine. My problem is that if I select any company from
the combo box.. the related records.. for eg. CustomerID, FirstName,
LastName, Billing Address.etc etc ..... in other words all the other field
does not change to reflect the record selected for the CompanyName selected
in the Combo Box!

I looked in the newsgroup under the heading "Populate Text Boxes with
selection of Combo Box" and followed the solution mentioned there.. but
still it does not work.. I dont know what I am doing wrong... the thread
says to do something like follows:
=[cboName].[Column](0)
=[cboName].[Column](1)
=[cboName].[Column](2)
and so on................


but when I click on the combo box the CustomerID and Billing Address and
other field goes Blank...
How can I achieve this ?
I hope I have made myself clear.

Also I tried to get the "combobox wizard" started but did not succeed.. Is
it required to be installed as an Add In? How can I see the combobox wizard
to work on a form??

I would appreaciate any help in this matter.



.
 
K

Kevin Sprinkel

Format:Column Count = 4
Data:Control Source = "" (nul or no value)
Input mask = ""
Row Source Type = "Table/Query"
Row Source = "select cust.name, cust.addr1, cust.phone, cust.city from
cust"
Bound Column = 1
Event:none set
This gives me a drop down menu from which I can select any one of my
customers. (this is good) In this drop down I can also see the other 3
fields that are identified in the query. (this is not
good)

--- Set the combo box' Column Widths property to zero for
all columns you do not wish displayed, e.g.:

2";0";0";0"
What I want to do is add the 3 other fields (text boxes) to my form in
random locations (to fit a pre-printed form) to show the other 3 values that
are related to the record that is chosen from the combo- box.
Try as I might I can't seem to make this happen. I'm guessing what I'm doing
is slightly different than the explanation given to Nasir because of the
random locations.

-------- No, the location shouldn't matter. What's
important is the textbox' Control Source property. Since
the address is the second column of your textbox (index
1), the Control Source should be set to:

= Me!<yourcomboboxname>.Column(1)

Be sure to use the *name* of the combo box, not the name
of the field it displays. This is a common error. By
default, Access names combo boxes Combo1, Combo2, etc.
Effective developers rename the box to a more meaningful
name, including using the Lesynski naming conventions,
e.g., cboAddress.


--------- One more general comment: if you're trying to
duplicate an existing paper form so that it *prints*
similarly, you should be aware that printing a form is
very limited. The report writer is much more versatile.

HTH
Kevin Sprinkel
Any help will be appreciated.
Steve

Hello, Nasir.

Your approach is OK, provided you're not trying to *store*
these other fields in the form's underlying table. The
Company ID fully defines the record, there is no need to
store the other fields in the Orders table. So I'll
assume for now that you just wish to *display* the other
Company fields. In order to use the Column method on your
combo box, you must include all the fields of interest in
the Row Source of the combo box. Let's say you include the
following fields:

CompanyID
CompanyName
Address
City
State
Zip

in a combo box named cboCompany. Column is zero-based, so
to refer to CompanyName, you would use cboCompany.Column
(1).

This can be done most easily with the wizard. There is a
toggle button on the Toolbox toolbar. It looks like a
wizard's wand and several stars. Choose View, Toolbox if
this toolbar is not active. Once the wizard is toggled
on, it will invoke automatically when you attempt to place
a new combo box.

If you're new to combo boxes, most developers generally
hide the primary key field, such that the combo box
displays the second row (index=1), in the example above,
CompanyName, yet the primary key value is what is actually
stored in the form's underlying table. This behavior is
controlled by the controls' Bound Column and Column Widths
properties. The wizard will set them for you, but to hide
the first column manually, set its width to 0".

HTH
Kevin Sprinkel
-----Original Message-----
Hello Group

I tried to search this problem in the newsgroup but failed (due to my very
limited knowledge).

I have used the template of Access 2002 and created the Order Entry
database.

I changed the CompanyName text box to a combo box on the "Orders by
Customer" form and set its RowSource to show the
company
names in Ascending
order and it works fine. My problem is that if I
select
any company from
the combo box.. the related records.. for eg.
CustomerID,
FirstName,
LastName, Billing Address.etc etc ..... in other words all the other field
does not change to reflect the record selected for the CompanyName selected
in the Combo Box!

I looked in the newsgroup under the heading "Populate Text Boxes with
selection of Combo Box" and followed the solution mentioned there.. but
still it does not work.. I dont know what I am doing wrong... the thread
says to do something like follows:
=[cboName].[Column](0)
=[cboName].[Column](1)
=[cboName].[Column](2)
and so on................


but when I click on the combo box the CustomerID and Billing Address and
other field goes Blank...
How can I achieve this ?
I hope I have made myself clear.

Also I tried to get the "combobox wizard" started but
did
not succeed.. Is
it required to be installed as an Add In? How can I
see
the combobox wizard
to work on a form??

I would appreaciate any help in this matter.



.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.596 / Virus Database: 379 - Release Date: 2/26/2004


.
 
G

GSteven

Kevin,

I appreciate your reply and am asking of your patience.

As advised I set the Column Width properties which corrected the other
columns showing up in the combobox. I also renamed the combo box to
"cboCUST". I then used this name in the Control Source property of the text
box (named txtADDR) which is set to: = Me!cboCUST.Column(1)

When I open the form in view mode all I see in the text box is "#Name?". The
help for this error says that the MSOWF.DLL file is missing yet I find this
dll in the "c:\program files\Microsoft Office\Office" folder. What is this
"Me" function you are using and where can I find help on it?

Steve

Kevin Sprinkel said:
Format:Column Count = 4
Data:Control Source = "" (nul or no value)
Input mask = ""
Row Source Type = "Table/Query"
Row Source = "select cust.name, cust.addr1, cust.phone, cust.city from
cust"
Bound Column = 1
Event:none set
This gives me a drop down menu from which I can select any one of my
customers. (this is good) In this drop down I can also see the other 3
fields that are identified in the query. (this is not
good)

--- Set the combo box' Column Widths property to zero for
all columns you do not wish displayed, e.g.:

2";0";0";0"
What I want to do is add the 3 other fields (text boxes) to my form in
random locations (to fit a pre-printed form) to show the other 3 values that
are related to the record that is chosen from the combo- box.
Try as I might I can't seem to make this happen. I'm guessing what I'm doing
is slightly different than the explanation given to Nasir because of the
random locations.

-------- No, the location shouldn't matter. What's
important is the textbox' Control Source property. Since
the address is the second column of your textbox (index
1), the Control Source should be set to:

= Me!<yourcomboboxname>.Column(1)

Be sure to use the *name* of the combo box, not the name
of the field it displays. This is a common error. By
default, Access names combo boxes Combo1, Combo2, etc.
Effective developers rename the box to a more meaningful
name, including using the Lesynski naming conventions,
e.g., cboAddress.


--------- One more general comment: if you're trying to
duplicate an existing paper form so that it *prints*
similarly, you should be aware that printing a form is
very limited. The report writer is much more versatile.

HTH
Kevin Sprinkel
Any help will be appreciated.
Steve

Hello, Nasir.

Your approach is OK, provided you're not trying to *store*
these other fields in the form's underlying table. The
Company ID fully defines the record, there is no need to
store the other fields in the Orders table. So I'll
assume for now that you just wish to *display* the other
Company fields. In order to use the Column method on your
combo box, you must include all the fields of interest in
the Row Source of the combo box. Let's say you include the
following fields:

CompanyID
CompanyName
Address
City
State
Zip

in a combo box named cboCompany. Column is zero-based, so
to refer to CompanyName, you would use cboCompany.Column
(1).

This can be done most easily with the wizard. There is a
toggle button on the Toolbox toolbar. It looks like a
wizard's wand and several stars. Choose View, Toolbox if
this toolbar is not active. Once the wizard is toggled
on, it will invoke automatically when you attempt to place
a new combo box.

If you're new to combo boxes, most developers generally
hide the primary key field, such that the combo box
displays the second row (index=1), in the example above,
CompanyName, yet the primary key value is what is actually
stored in the form's underlying table. This behavior is
controlled by the controls' Bound Column and Column Widths
properties. The wizard will set them for you, but to hide
the first column manually, set its width to 0".

HTH
Kevin Sprinkel

-----Original Message-----
Hello Group

I tried to search this problem in the newsgroup but
failed (due to my very
limited knowledge).

I have used the template of Access 2002 and created the
Order Entry
database.

I changed the CompanyName text box to a combo box on
the "Orders by
Customer" form and set its RowSource to show the company
names in Ascending
order and it works fine. My problem is that if I select
any company from
the combo box.. the related records.. for eg. CustomerID,
FirstName,
LastName, Billing Address.etc etc ..... in other words
all the other field
does not change to reflect the record selected for the
CompanyName selected
in the Combo Box!

I looked in the newsgroup under the heading "Populate
Text Boxes with
selection of Combo Box" and followed the solution
mentioned there.. but
still it does not work.. I dont know what I am doing
wrong... the thread
says to do something like follows:
=[cboName].[Column](0)
=[cboName].[Column](1)
=[cboName].[Column](2)
and so on................


but when I click on the combo box the CustomerID and
Billing Address and
other field goes Blank...
How can I achieve this ?
I hope I have made myself clear.

Also I tried to get the "combobox wizard" started but did
not succeed.. Is
it required to be installed as an Add In? How can I see
the combobox wizard
to work on a form??

I would appreaciate any help in this matter.



.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.596 / Virus Database: 379 - Release Date: 2/26/2004


.
 
K

Kevin Sprinkel

Me is a shorthand provided by Access to refer to the
current form. For reasons I must investigate, it
apparently does not work in this context. Normally, to
refer to a control named cboCust on a form named
frmCustomers, you can use either of the following
interchangeably:

Forms!frmCustomers!cboCust
Me!cboCust

Change your Control Source, referring explicitly to the
formname, like the first example above.

Kevin Sprinkel
 
N

Nasir Khan

Hi Kevin,
I am sorry .. I was out of town for a week.. just came back and saw your
reply.

Thanks a lot.. I can achieve what I wanted thru the combo box wizard.
If I have any other query... I will revert back.
Thanks once again.

Nasir
Kevin Sprinkel said:
Hello, Nasir.

Your approach is OK, provided you're not trying to *store*
these other fields in the form's underlying table. The
Company ID fully defines the record, there is no need to
store the other fields in the Orders table. So I'll
assume for now that you just wish to *display* the other
Company fields. In order to use the Column method on your
combo box, you must include all the fields of interest in
the Row Source of the combo box. Let's say you include the
following fields:

CompanyID
CompanyName
Address
City
State
Zip

in a combo box named cboCompany. Column is zero-based, so
to refer to CompanyName, you would use cboCompany.Column
(1).

This can be done most easily with the wizard. There is a
toggle button on the Toolbox toolbar. It looks like a
wizard's wand and several stars. Choose View, Toolbox if
this toolbar is not active. Once the wizard is toggled
on, it will invoke automatically when you attempt to place
a new combo box.

If you're new to combo boxes, most developers generally
hide the primary key field, such that the combo box
displays the second row (index=1), in the example above,
CompanyName, yet the primary key value is what is actually
stored in the form's underlying table. This behavior is
controlled by the controls' Bound Column and Column Widths
properties. The wizard will set them for you, but to hide
the first column manually, set its width to 0".

HTH
Kevin Sprinkel
-----Original Message-----
Hello Group

I tried to search this problem in the newsgroup but failed (due to my very
limited knowledge).

I have used the template of Access 2002 and created the Order Entry
database.

I changed the CompanyName text box to a combo box on the "Orders by
Customer" form and set its RowSource to show the company names in Ascending
order and it works fine. My problem is that if I select any company from
the combo box.. the related records.. for eg. CustomerID, FirstName,
LastName, Billing Address.etc etc ..... in other words all the other field
does not change to reflect the record selected for the CompanyName selected
in the Combo Box!

I looked in the newsgroup under the heading "Populate Text Boxes with
selection of Combo Box" and followed the solution mentioned there.. but
still it does not work.. I dont know what I am doing wrong... the thread
says to do something like follows:
=[cboName].[Column](0)
=[cboName].[Column](1)
=[cboName].[Column](2)
and so on................


but when I click on the combo box the CustomerID and Billing Address and
other field goes Blank...
How can I achieve this ?
I hope I have made myself clear.

Also I tried to get the "combobox wizard" started but did not succeed.. Is
it required to be installed as an Add In? How can I see the combobox wizard
to work on a form??

I would appreaciate any help in this matter.



.
 

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