A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Using a combo box for setting a name



 
 
Thread Tools Display Modes
  #1  
Old May 14th, 2005, 06:47 PM
Ian Melnick
external usenet poster
 
Posts: n/a
Default Using a combo box for setting a name

Hello all,

I have two tables, each with primary key "id". Table1 has fields "First
Name" and "Last Name", while Table2 has field "user", which is a number.
I want to set up a combo box in a form for Table2 that will correctly
set the "user" from Table2 to the "id" from Table1. It also needs to
display the first name and last name (by referring to the stored user
field) correctly when the record is accessed.

In other words, it needs to list all first and last name info from
Table1, and when a name is selected, store it in Table2 as the id from
Table1. When the record is accessed by the form, it needs to correctly
display the name as defined by the id stored in the "user" column. How
do I do this?

Thanks


  #2  
Old May 14th, 2005, 09:08 PM
tina
external usenet poster
 
Posts: n/a
Default

your form should be bound to Table2. the combo box on the form should be
bound to the User field from Table2. set the combo box's properties as
follows:

RowSourceType: Table/Query
RowSource: SELECT ID, FirstName & " " & LastName As FullName FROM Table1
ORDER BY FullName;
ColumnCount: 2
ColumnWidths: 0"; 1.25"
BoundColumn: 1
ListWidth: 1.5"

the combo box's droplist will show first and last names. when you choose a
name, the value stored in the User field will be the ID that goes with that
name.

hth


"Ian Melnick" wrote in message
...
Hello all,

I have two tables, each with primary key "id". Table1 has fields "First
Name" and "Last Name", while Table2 has field "user", which is a number.
I want to set up a combo box in a form for Table2 that will correctly
set the "user" from Table2 to the "id" from Table1. It also needs to
display the first name and last name (by referring to the stored user
field) correctly when the record is accessed.

In other words, it needs to list all first and last name info from
Table1, and when a name is selected, store it in Table2 as the id from
Table1. When the record is accessed by the form, it needs to correctly
display the name as defined by the id stored in the "user" column. How
do I do this?

Thanks




  #3  
Old May 15th, 2005, 07:00 AM
Ian Melnick
external usenet poster
 
Posts: n/a
Default

Thanks; is there a way to have it convert the stored ID number to the
FullName when the record is returned to after input? Right now I'm
seeing the list of names in the combo box, with the set value being the
ID number that was set previously---what I'd like to be able to do is
see the name instead.

Thanks again




your form should be bound to Table2. the combo box on the form should
be



  #4  
Old May 15th, 2005, 07:29 AM
tina
external usenet poster
 
Posts: n/a
Default

you do want the ID value to be stored in the field, rather than the name,
because the ID value is the primary key in Table1. if you set the combo box
up the way i described, you *will* see the name displayed in the combobox
control of each record in the form, rather than stored ID value. if you look
at the table itself, you will see the ID value, which is correct. the end
user should never open a table; all data entry and review should be done via
forms and reports.

if you're seeing the ID value in the combo box control of the form, rather
than the name, then your combo box setup is incorrect. look at the list of
combo box properties i posted, and post the actual value of those properties
from your combo box.

hth


"Ian Melnick" wrote in message
...
Thanks; is there a way to have it convert the stored ID number to the
FullName when the record is returned to after input? Right now I'm
seeing the list of names in the combo box, with the set value being the
ID number that was set previously---what I'd like to be able to do is
see the name instead.

Thanks again




your form should be bound to Table2. the combo box on the form should
be





  #5  
Old May 17th, 2005, 06:58 PM
Ian Melnick
external usenet poster
 
Posts: n/a
Default

Thanks; this worked. I didn't have the object bound to the proper
control source, and once I set it up correctly, your directions worked
great.

Thanks again
ian






"tina" wrote in message
...
you do want the ID value to be stored in the field, rather than the
name,
because the ID value is the primary key in Table1. if you set the
combo box
up the way i described, you *will* see the name displayed in the
combobox
control of each record in the form, rather than stored ID value. if
you look
at the table itself, you will see the ID value, which is correct. the
end
user should never open a table; all data entry and review should be
done via
forms and reports.

if you're seeing the ID value in the combo box control of the form,
rather
than the name, then your combo box setup is incorrect. look at the
list of
combo box properties i posted, and post the actual value of those
properties
from your combo box.

hth



  #6  
Old May 17th, 2005, 07:38 PM
tina
external usenet poster
 
Posts: n/a
Default

you're welcome


"Ian Melnick" wrote in message
...
Thanks; this worked. I didn't have the object bound to the proper
control source, and once I set it up correctly, your directions worked
great.

Thanks again
ian






"tina" wrote in message
...
you do want the ID value to be stored in the field, rather than the
name,
because the ID value is the primary key in Table1. if you set the
combo box
up the way i described, you *will* see the name displayed in the
combobox
control of each record in the form, rather than stored ID value. if
you look
at the table itself, you will see the ID value, which is correct. the
end
user should never open a table; all data entry and review should be
done via
forms and reports.

if you're seeing the ID value in the combo box control of the form,
rather
than the name, then your combo box setup is incorrect. look at the
list of
combo box properties i posted, and post the actual value of those
properties
from your combo box.

hth





 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
combo question rob New Users 10 March 21st, 2005 02:05 PM
Subform Refresh Problem (but only with an unbound combo box control) Barry Skidmore Using Forms 1 December 21st, 2004 01:19 AM
Combo box lookup doesn't work when field is blank/null Bob Richardson General Discussion 11 July 27th, 2004 06:21 PM
Combo Box Problem Charles Using Forms 0 May 28th, 2004 09:15 PM
Requery Combobox MJ Running & Setting Up Queries 7 May 25th, 2004 11:01 AM


All times are GMT +1. The time now is 08:46 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.