I created tables within Access. I created primary and secondary keys and created the relationships one to many. However, when working with forms (Primary form and submform) when updating and scrolling through the primary form the primary table changes. I would really want the primary table not be able to be changed except when in a separate process. I have deleted the relationship recreated them and also deleted all the forms and recreated them. How do I lock the primary table/form?
Related
I'm writing an application that reads data from a relational database, let's the user change the data, and writes it back.
I am unsure how to deal with the primary keys since I do not want to show them in the user interface output. What are good practices to hold the primary keys invisible for the user but so that they can easily be retrieved after the changes in the gui are made?
I use C#, Windows Forms and sqlite, if needed.
EDIT: Example: I have a text input that contains the wage of a employee. Can I save the the primary key of that employee bound to that text input, so that changes made by the user can be written back easily?
If you're using an ORM you have the PK as a property of the object. If you're using SQL queries directly you can hold PK in an internal variable in your form class.
Would I run into any issue if I tried dropping a foreign key constraint on a live SQL database? I want to make sure there's no reason to take the database offline before doing this.
Dropping a foreign key on the live databases can be done online without impacting your users. You may run into data quality issues though, I guess the foreign key was in place for a reason.
I have started working on an existing frontend MS Access application built with VBA. It is linked to a backend Access database. So basically there are two Access databases - one frontend and one backend.
Because of the nature of the work involving vehicles, each user has their own copy of identical database with their individual data stored in backend. Constant Access to one backend db via internet is not really possible as the users are able to connect to internet (network) once a day only. Right now we just copy each backend database via ftp and store it as usr_backenddb_date.accdb
Backend databases contain around 16 tables with most of them containing an autonumber field as a primary key. Further tables are connected with each other referencing the primary key as a foreign key. I would ideally like to create a function in vba that lets me select the database and merge all the data from that database to an identical central database. For the initial part, I am thinking of doing something like this How to merge two identical database data to one? with possibly trying to cascade the change in autonumber field so the references remain intact.
I wanted to know if this approach is doable or if anyone has any other ideas and suggestion that I can look into.
We have an in-house program at the company I work for, and inside of MS Access we link all of our tables to our three databases. However; in order to create new routes for students, someone needs an isolated copy of our program to work with that won't impact the actual database.
After deleting the linked tables, importing them all locally, and saving the .mdb I can no longer change values inside of most forms. For example:
A drop down menu with a list of possible route codes for a student will appear. Usually you can select one. You are no longer able to, and in the bottom left hand corner you see "this recordset is not updateable".
I'm a bit new at this, but I can't imagine why importing the tables would break anything. I wouldn't expect any key violations to occur (like I might when linking tables), or anything of that nature. If anyone can point me in the right direction it would be much appreciated! Thanks!
Access can handle a compound primary key on a linked table or view. The important thing, of course, is to make sure you're telling Access the right fields to use. It's common for Access not to get the primary key info when you're linking to a view (perhaps the ODBC driver doesn't pass that info along?), but I bet it can happen with tables too.
Not sure if these pics will help, but hopefully it can point you in the right direction. Here's a linked view, as you can see in this picture:
If you open it in design view, you can see that there are no primary keys:
which means that the table isn't editable (the add new button is greyed out):
So I run this command to tell Access to use a compound primary key on the linked view:
CurrentDb.Execute "Create Unique Index PrimaryKey On View_AssnsWithSorterField([Serial No], AssignmentDate)"
If you open the linked view in design view again, you can see the compound primary key:
and now the add new button appears.
You said that you tried to add a compound primary key but Access wouldn't allow it, which sounds like there's something about the table's data or structure that prevents it from using that key. How about creating an empty copy of the table in the backend database, then try linking to that? If that still doesn't work then maybe there's a unique constraint, or a trigger, or something else on the table that causes Access not to like making it updateable. Conversely, if it links fine and you can add/edit records in the linked blank test table, then it must be data in the real table that's causing the issue.
Sometimes if you cut down a copy of the table into smaller chunks (like maybe just start with the primary key columns alone) and gradually rebuild it piece by piece, you eventually hit on the thing that makes Access not let it be updateable.
One other possibility, of course, is a problem with the driver itself. The ODBC drivers that link to SQLServer and Oracle are good quality and can handle complex primary keys, but I've used junky drivers that link to obscure databases and they couldn't handle complex things like subqueries, union queries, etc, even though you could do those things in the database itself; the driver was only written to handle basic select/insert/update/deletes and that was it.
I'v created a ER model in data modeler and one of the entity is automatically setting a primary key even though I dont want a primary key to that particular entity.. here is a screenshot As you can see on logical model there is no staff_type_id
but the relational model has staff_type_id
why is this happening? its creating a problem while i implement the database. Please help :(
I think there's no problem in that, if you notice you are linking the two tables with a relation of 1:N and you can't link entities that don't have primary key. it's the best to create a primary key for every linked entity. How you can link between entities without foreign key and primary key?!
generally, it's recommended to give every linked entity primary key.
I don't understand how this is a problem! can you explain more?