Queries based on forms and MS Access development - ms-access

i have 2 questions when i use access:
i create a form with comboBox and calenders, i want to choose an employee
from combobox and from date and to date and when i click ok i will send these
parameters to a query to return the result in a query (result is the calculation
of it's salary).
i know how to release an access project to be useful to user that can't
access tables and queries only forms.
is there any way to change the access project from release mode to development
one, because supposed that an error occurred, how to solve it without loosing
my data.
Note: i don't have client/server i develop a program and i release it and
give this release to the user, after a specific time this user tell me that
an error occurred, and he need data inserted from this program to database.
i can solve this problems and release another version of program, but the
main problem is how to take all data from the old program to the new one.

-- You can reference form control in a query:
SELECT FROM MyTable
WHERE EmployeeID = Forms!MyForm!cboEmployee
AND SomeDate BETWEEN Forms!MyForm!txtDateStart And Forms!MyForm!txtDateEnd
You could also build an SQL string and use it as the record source for a form or in VBA.
-- Access should be split into front-end (forms, reports, etc) and back-end (data). When you make changes to the front-end, you create a new mde or accde and send that to the users. The data stays on a server in the back-end.
See: http://msdn.microsoft.com/en-us/library/aa167840(v=office.11).aspx
EDIT
From your comments, it seems that each application has a single user, if this is the case, splitting is not essential, but it can still be a good idea. The user will get two databases, one for data and one for forms etc and only the one for forms gets replaced. You will need to include a routine to locate and link the back-end tables.
However, if this is not possible, an mde or accde does not hide the data, you can send your revised copy and include a routine to import from the previous mde/accde.
EDIT 2
There are wizards that will split your database for you and link the tables. Where you find them varies slightly from version to version, but they are under the menu item Database Tools. The only problem with this is that the linked table holds the location for the back-end, which is on your computer, not on your users computer. Linked tables are how you access data in the second database. These act as if there are tables in the first database, except you cannot change them. Unfortunately, linked tables hold the location of the back-end, so this will have to be changed if you are sending it to a users. You can either write code, or show your user how to use the linked table manager. This may lead to confusion and may not be worth the effort for one PC. (See also http://www.alvechurchdata.co.uk/accsplit.htm)
Alternatively, you can split the database on your PC and make all the changes to forms etc that you want, then add some code that will import the tables and other data for the user into your new copy. The user will follow the instructions in your code to import the tables. As an aside, you will find that development is a lot safer on a split database. You should also decompile from time to time, which you can find at http://www.granite.ab.ca/access/decompile.htm.
If you want to protect your code, you can create a compiled version of this new copy, the extension for a compiled Access database is *.accde, for 2007 onward and *.mde for prior versions. This is what I thought you meant by 'i know how to release an access project'.

Related

How to manage "releases" with MS Access

I have an MS Access 2016 application that a few people use in one department. I know this whole thing has web dev written all over it but this access database has been their process for a while and there is no time right now to switch over.
Recently, a different department wants to use this application, but having their own copy. Currently, if I need to make changes, I'll make the changes in a copy of the app, they send me a current version when I'm ready to import their data, I import it and send them back a new one. However, currently I copy the data table by table and past it into the new database. This is inefficient and tedious, and now with 2 sets of data I'd be doing this for, that's crazy. There's over 20 tables so I don't want to have to manually copy over 40+ tables across the 2 apps for even the smallest change like altering a message to the user.
I know I can copy the code so I can avoid importing the data, but sometimes for big changes I'll change over 15-20 vba files.
So, a couple questions:
1.Is there a way to generate insert statements for the entire database that I could run in a script? So when I create the new copy I just upload 1 file and it populates all the data?
2.Are there any kind of dev tools that will help this process? Right now I'm thinking that it's just a downfall of creating an MS Access app, but there must be some way that people have made the "new release" process easier. My current system seems flawed and I'm looking to have a more stable process.
EDIT:
Currently I have all my data stored locally, attached to the same access file as the front end. Since I will have 2 different departments using the same functionality, how do I manage the data/the front-end? These 2 departments should have their own access file to enter data using the forms, so having 1 front end between the 2 departments won't work.
Also, should I create 2 separate back-ends? Currently I would have nothing to distinguish what is being inserted/changed/deleted from one department from the other. If I were to attach a field specifying who entered the record, that would require a complete overall of all my queries which I don't have the time for as there are deadlines I need to meet.
First thing is to split the database. There is a wizard for this.
Then you can maintain the frontend without touching the real data.
Next, consider using a script to distribute revised versions of the frontend. I once wrote an article on one proven method to handle this:
Deploy and update a Microsoft Access application in a Citrix environment

Transfering an entry and all its relations to another Access DB VBA

I've just been assigned the task to create another Access DB whose data is a subset of the master DB. I didn't build the original DB and I'm just stuck in trying to create this functionality.
Depending on a Boolean value (which I will have to integrate into the DB) each entry will dictate if all the entries data will be shared or if only a portion of the data will be shared. By sharing I mean transferring the entries into a mirror DB that is located in a folder that a wider group of people has access to.
I don't know how to even start but I'm guessing that the relations structure that the person who built the DB will be helpful for when I erased an entire entry in the DB it erased all data in other tables related to my entry as well.
For added "fun" I'm suppose to manage a C.R.U.D. system for this subset in case either a person accidentally clicks on the share button (Create) and wants to unshared the data (Delete) or when part of the original gets updated and the mirror then needs to get updated as well (Updated).
I'm hoping to get a few good ideas as to how to proceed.
Limitations and Info that I see might be relevant.
-The original DB is located in a folder whose permissions are restricted to people entering data.
-Can't use third party applications that require an install.
-The mirror DB does not have to updated automatically when the master DB updates. It can be restricted to when a user clicks a button called "Updated Mirror DB". (Only if this would provide a simpler solution)
-The process can be as slow as molasses in winter as long as it is robust.
-I have decent VBA skills when it comes to working in Excel but it lacks when related to Access.
-Users who create and manage the data have read and write access to both the folder that the master DB is in and as well the mirror DB.
-Using Access 2007 - 2010
Thanks everyone for take a look at this. If you would require more info to provide assistance please just ask and I'll do my best to acquire it.
Seeing as you have decent vba, and you're limited to apps which don't require an install, I suggest you do it as an excel vba app. VBA has all the functionality you'll need to copy databases from one spot to another on the file system, compact and repair (adox), drop tables you don't need, insert/update/delete etc.
Depending on which info you need to persist to the mirror db, it may be easier to simply make a copy of the master db and delete irrelevant tables (if it's only certain tables you need to mirror). If it's a subset of data in each table, you may find the best way would be to make a template db, which is a copy of the master db but with no data, then create a vba process to copy the template db, create linked tables in this one back to the master, then run sql to insert into the local tables select (whatever data you need to mirror) from the master tables.
All of this can be done in vba, and your users end up with an excel interface which will be very familiar. Good luck.

How to protect Access database and limit to certain computers

Good morning,
I'm doing a project, the customer prefers to use Access 2013 as the all in one package - front end, database etc.
In short the customer will give their users a blank copy of the database, which is taken on site and used to generate data based on calibration of equipment for that site.
The problem is the customer doesn't want anyone being able to copy the access database and use it themselves. So basically when on site he doesn't want the customer or anyone to go "oh that database is hand, give me a copy and I'll use it for myself".
I know I can compile the database but that will only protect the source.
Any suggestions on the best way to limit the use of the database?
It's been a few years and I may be foggy on parts of this, but I know you can get around password protected databases, and can bypass the 'startup' form/code so that you can open the database and view all the objects. You are correct that an MDE will not show the code. But if you have a table of valid serial numbers or MAC Id's, then I would have a module that encrypts the data in that table. Otherwise someone could add their values and still run the program? We also did some devious things like create an install package that would create some hidden file in some existing folder (with a calculated value as content), then if Access didn't find that file & content it would not run.

Data changing and reverting - MS Access frontend for SQL Server backend

I have come across a very frustrating and perplexing problem. I have been all over google and have been unable to find anything about it.
System specs:
I am running an Access .mdb front end with a SQL Server back end. The tables all have primary keys declared and foreign key relationships. The SQL Server tables are linked to the Access front end via ODBC. A single copy of the Access front end file is located in a shared network location and is accessed by multiple users at any given time. There are about 15 to 20 users that could have an instance of the Access front end file open on their machine. In the front end file there are a lot of queries, forms, and reports. All of the forms and reports have some amount of vba that go along with them. The SQL Server is the Express edition of 2008 R2. All of the user are running Office 2007.
Problem:
I spent a great deal of time updating data in our system about two years ago. Over the last couple of months users have been telling me that data is missing or incorrect when I know that it should be correct after my updates. Because I create backups for the SQL Server database periodically, I was able to look at older version of the database and discovered that the data had in fact been updated as I thought, but now those line of data are missing or incorrect. I am the only person who knows how to update data en masse, and no one would go in and intentionally alter this data. It is widespread enough, that I know it is not the result of an accidental keystroke.
The front end does have some built in features that are used for copying data which I did not create. (In fact I inherited this whole system, and have just made additions and modifications here and there) We are a manufacturing firm that creates custom versions of our standard products, so bills of materials often need to be copied, then modified for the custom version. Yesterday I executed such as copy and ended up with a crazy result. When I copied the bill of materials from the original, it copied an old version of the original product's bill of materials into the custom version's bill. It was insane. I double checked the bom of the original and it was the up to date version, but somehow the old version of the bom ended up copying into the custom product's bom. The only thing I can think of, is that somehow the old data has managed to store itself (from as long as two years ago) in the Access front end, and somehow that data was pulled from by the vba that executes the bom copy function.
Has anyone seen something like this before?
Just a suggestion; use a distributed front end method. It's an industry standard, as it's a known fact that a shared front end can lead to corruption. Each user should have a copy of the front end on their local HD, and it's easy enough to distribute using a simple BAT file to copy the front end from the network to the HD.
Aside from that, data doesn't magically revert to ancient records. It's pulling that data from somewhere. You will need to track the data path and see where it originated from. Look at the code behind the "Copy" button. If it's pulling from a linked table, open that table in SQL Server and run the SQL that the Copy function is executing and see if the resulting data is identical to what Access thinks it is. If not, write a SQL string to filter the data based on what Access returned and see if that record still exists in the table. If it does, look at each field and see if you can determine why it's pulling the old record instead of the new record. It's pulling this data from somewhere, you have to determine where that "somewhere" is.

Renaming fields in linked-table MDB file pair?

I have an Access 2003 database using MS-JET linked tables (that is, there are two *.mdb files). The overall task is to move to SQL server. However the existing databases have multiple fields with spaces and other characters that upset both of the Access migration wizards. So the intermediate task is to make a version of the existing mdb's with updated field names.
"Simply" changing field names in the UI mdb file doesn't work, because of the linked tables being read-only in that mdb. Updating the Data mdb file field names first doesn't work because the UI mdb then throws a wobbly on startup and Access gives up.
I'm looking for suggestions, but options I can see are:
re-integrate the Data mdb back into the UI one, do the updates, then re-export the data. Seems very risky to me (system is live, don't want to play with data any more than strictly necessary).
I've looked at several answers here relating to changing ODBC details with VBA code, which is interesting, and I can see how I might be able to programmatically edit the linked tables' names. Is this going to work? Is there a better way?
Unlink all linked tables, then edit in UI mdb the remaining forms, reports, queries (but would that work??) and edit the Data mdb fields, and finally relink everything. Will it fall apart?? ... seems likely.
Any suggestions?
Ruth
I go through this process every time I take over an existing Access application -- I have to bring it up to my own standards for naming conventions before I do anything significant with it. Recently I built a quick-and-dirty utility to rename fields. It was made for me and has very little error recovery, and a UI that is ugly, but it might be faster than doing it yourself.
See what track name autocorrect offers. How Name AutoCorrect Works in Microsoft Access
Make a copy of your UI MDB, delete the linked tables, then import them (as tables rather than links) from the Data MDB. Once you enable autocorrect, Access will attempt to propagate your field name changes wherever they are used (in forms for example). Unlikely it will catch 100% of the necessary changes, but it should resolve a big chunk of them. You would then need to manually track down and fix the rest.
Once you have everything fixed, you could use that MDB version to "upsize" your tables to SQL Server. However, one huge complication is if the original database is "live" while you're making changes to the new version. If you absolutely can't take the database out of service in the interim, you could discard the data from the new tables, then use "append" queries which alias the old to new field names to pull in the latest data.
INSERT INTO NewTable (emp_id, another_field)
SELECT
[emp ID],
[another field]
FROM OldTable IN 'C:\somefolder\Data.mdb';
Finally, a warning about autocorrect: do not leave it enabled in the production version of your database because strange things can happen. The safest approach IMO is to turn it on, complete your object name changes, then turn it back off again.
You might find Rick Fisher's Find and Replace tool helpful if you need to propagate name changes through the project. I've relied on it for years (though I don't do much Access development lately): http://www.rickworld.com/products.html
I think this tool will change the names of tables and fields for you but I am not sure. I mostly used it for finding references to tables and queries in other queries, form and report properties, and VBA code.