Solved

Access Database - Wrong column being saved

Posted on 2013-11-26
6
432 Views
Last Modified: 2013-12-22
Hi,
    I have two tables on my database called;

Data and Providers

Providers is made up of approx. 10 columns which are;

ID, Number, Name etc.

I have a form which has a drop down made up from the providers table, and when a record is saved, it saves the value to the Data table.... however....

On the dropdown box, it uses a SQL script to list the name, rather than the first column of ID, but when the record is saved, it saves it as the ID number, and NOT the name which is in the box on the form.

What am I doing wrong, and what do I need to do to resolve?

Thanks

Damian
0
Comment
Question by:damianb123
  • 3
  • 2
6 Comments
 
LVL 6

Accepted Solution

by:
ButlerTechnology earned 500 total points
ID: 39677411
It sounds like the ID is part of the drop-down list and that it is hidden -- in this case the width of the column is 0.  On the data tab of the drop-down, try setting the Bound Column to 2 to see if that corrects the issue.
Tom
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39677545
<<
What am I doing wrong, and what do I need to do to resolve?
>>

In the interest of keeping things normalized it actually sounds like you are doing things *right*.

In other words, you should maintain the provider name in ONE table (your providers table), and store the ID in others (such as your Data table).  You shouldn't store the name in multiple tables.  That way if the name changes (typos, etc), you only need to correct it in one place - the ID stored in any other tables is enough to look up the text name/description whenever needed.

(ie: you should leave this as is and adapt/develop your forms and reports to use the ID to lookup the name whenever needed)
0
 
LVL 34

Expert Comment

by:PatHartman
ID: 39677726
As mbizup already said, saving the ID is the correct solution to keep your tables normalized.  To see the text rather than the ID in reports, create a query that joins the two tables and select the text value from the lookup table.  You could use a combo as you do on forms but combos look awkward on reports.

For your own purposes, I know it's nice to see the descriptive value when you open the table but it doesn't take much effort to create a query that shows both.  Just be careful when you make such a query because you can update both sides of the join and you may inadvertently modify the text value thinking it applies only to the record you are looking at but in reality, it would change the value in the lookup table and so actually affect everyone.  So, in a query that joins an order to the customer table so you can see the customer name as well as his ID, if you change order.customerID to a different customer, Access will automatically populate customer.customerName with the correct customer name and the order will be reassigned to a different customer.  However, if you change customer.customerName, the change affects the customer table and that customer's name will be permanently changed where ever it is used.
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 61

Expert Comment

by:mbizup
ID: 39679723
Pat,

<<  but combos look awkward on reports. >>

Which view are you referring to?  

I've found that combos are a great way to handle relationships like this on reports... they look like combos in design view (and possibly in Report View in more recent versions of Access), but they display just like textboxes in Print Preview and in the print outs -- with the text rather than the ID displayed, and without the 'drop-down arrow'.
0
 
LVL 34

Expert Comment

by:PatHartman
ID: 39735237
I'm glad you got an answer to your question but unfortunately it enabled you to do the wrong thing.  Saving the ID is the correct solution.  You bring up the text value whenever you need it by using a query that joins to the lookup table.  Your accepted solution prevents the use of Referential integrity because you are saving the wrong field as the foreign key which is what mbizup and I were trying to tell you.  You need to save the ID field as the foreign key.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39735382
Agreed.  If you actually implemented that solution, you might want to revisit this question and independently read some articles / tutorials on database normalization.

As an aside, Experts-Exchange generally works best if there is more of an 'exchange' of comments... Your own participation/feedback is always a plus.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Creating and Managing Databases with phpMyAdmin in cPanel.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now