Question How can I load combo from field (1 Viewer)

engineer

Registered User.
Local time
Today, 01:27
Joined
Apr 5, 2009
Messages
15
I have table A contains many data about persons
I have table B which has a combobox in the field of Name
I want to load it with the names of persons from table A
can you help me ?
 

boblarson

Smeghead
Local time
Today, 01:27
Joined
Jan 12, 2001
Messages
32,059
I have table A contains many data about persons
I have table B which has a combobox in the field of Name
I want to load it with the names of persons from table A
can you help me ?

1. Don't do lookups like that in tables. Do them on FORMS.
See here for why:
The Evils of Lookups in Tables
2. How about a detailed structure of your tables instead of a real generic description. My guess is that you may not have them exactly optimized (but I could be wrong).
 

engineer

Registered User.
Local time
Today, 01:27
Joined
Apr 5, 2009
Messages
15
Thanks mr.boblarson for this orientation and for good link

let me ask again with the right questio
How can I load combo in form of table A from table B

for more details
I have table A ( Id - Name - Phone - Address )
which contain the personal data of every customer to permit connections with him
Address help us to delivery orders to home and phone to contact him .
table B to register every order for each customer
so I want make a form for this table to show the name of customers in a combobox from table A ( field Name )
I hope my details are clear

My question is
How can I load combo in form of table A from table B
 

boblarson

Smeghead
Local time
Today, 01:27
Joined
Jan 12, 2001
Messages
32,059
Okay, what you want to do is to store the ID in table B (I would change the field name from ID to PersonID and then also have the field PersonID in table B as it is easier to know what relates to what than just ID).

In Table A, PersonID should be an Autonumber but in Table B, PersonID should be a Long Integer.

See my simple combo box sample here:
http://downloads.btabdevelopment.com/Samples/combos/ListboxComboSample.zip

which hopfully will make sense. The combo's ROWSOURCE property is where you get the values from TableA but the combo's BOUND to a field in TableB and the "bound column" property in the sample is bound to the ID and not the text (which is how it should be)
 

engineer

Registered User.
Local time
Today, 01:27
Joined
Apr 5, 2009
Messages
15
Thanks mr.boblarson for your interest
but I am so sorry your example is so far than what I ask about

I don't need any relation between the tables
only I want data from one field is loaded in another field combo because I want preventing users from entering any data in this field only choose from combo
Is it clear ? I hope that
 
Last edited:

g28dman

Registered User.
Local time
Today, 03:27
Joined
Nov 4, 2005
Messages
84
If you study form 2 (the reference of the combo box) of Larson's example I think you will find what you are looking for.


Thanks mr.boblarson for your interest
but I am so sorry your example is so far than what I ask about

I don't need any relation between the tables
only I want data from one field is loaded in another field combo because I want preventing users from entering any data in this field only choose from combo
Is it clear ? I hope that
 

engineer

Registered User.
Local time
Today, 01:27
Joined
Apr 5, 2009
Messages
15
the code which used in form2 for show the data in combo is
SELECT [tblPersons].[PersonID], [tblPersons].[PersonName] FROM tblPersons;
which mean showing only the data from another table

but I want show the data from to field to add it in another field , is it clear ?

remember that my question is
How can I load combo in form of table A from table B

more details :
table A has a form A . I make a combo in form A to add data in table A ,
I want to fill the menu of combo with data from table B
 

boblarson

Smeghead
Local time
Today, 01:27
Joined
Jan 12, 2001
Messages
32,059
You should not be adding the same information from one field in a table to another field in the same table. That is a no-no in the relational database world. What exactly is the field (what are some SPECIFIC examples) and why do you need it in another field in the same table?
 

Users who are viewing this thread

Top Bottom