Access SQL / VBA how to display name instead of ID with relationships

Hi
Assuming I have 2 tables
Table1
Table1ID (Autonumber)
Name (Text)

Table 2
ID (Autonumber)
Table1ID (for table relationship)
wathebver (text)


I want to create table 2 programatically

CREATE TABLE Table2
(
   IDAUTOINCREMENT PRIMARY KEY,
   Table1ID INTEGER NOT NULL CONSTRAINT FK_Table1ID  
        REFERENCES Table1 (Table1ID),
    NoteDate DATETIME
)

this is creating the relationship but the display in the table is the ID from table 1, how can i change that to be the "Name" field in Table1 like when i do it from the wizard in Access?

thank you
LVL 49
AkhaterAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongCommented:
>>Table1ID INTEGER NOT NULL CONSTRAINT FK_Table1ID  
        REFERENCES Table1 (Table1ID)

you had already referred to the field name, which is Table1ID
0
Ryan ChongCommented:
meaning to say...

FK_Table1ID  
        REFERENCES Table1 (yourfield)

in your case, change "yourfield=" to "name="
0
Ryan ChongCommented:
typo. in your case, change "yourfield" to "name"
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

AkhaterAuthor Commented:
It was the first thing I tried but it doesn't work, "NO Unique index Found for the referenced field in the primary table"

the ID is the unique but i want the name to dispaly

thanks
0
hnasrCommented:
The relation is right.
And this is the stage of collecting data.

Next stage is to display and use data.
To display the name, you need to join the two tables, and include the name in the recordset.

SELECT table1.Id, table2.[name]
FROM table1 INNER JOIN table2  ON table2.table1ID=table1.table1ID

Open in new window

0
AkhaterAuthor Commented:
no the problem was not from the SQL but from the properties of the table

had to change ColumnCount to 2 and ColumnWidth to 0";1"
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hnasrCommented:
This suggests the properties of a combo box, and comes under data display.
0
Ryan ChongCommented:
had to change ColumnCount to 2 and ColumnWidth to 0";1"
ok... think it was a bit vague and the issue was not being explained clearly.

anyway, glad that you found the solution.
0
PatHartmanCommented:
Combos do not belong on tables.  They belong on forms.  There are lots of expert warnings to not use this "feature".  You will run into trouble with VBA and queries.  Since users never open queries or tables directly, only the developer ever actually would see this combo on the table and if the developer needs to see the lookup value, he can create a query that joins the main table to the lookup table.
0
AkhaterAuthor Commented:
Thank you for the help
solved it myself
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.