Microsoft Access - Include Last Modified By [duplicate] - ms-access

This question already has answers here:
How to use system username directly in MS Access query?
(4 answers)
Closed 4 years ago.
I'm setting up a Data Update Form for my Access table for records to be updated. I just included a Last modified Date and Time fields, however, I was wondering was there anyway I could capture the user who was doing the update? Thanks

When I do this, i typically keep a variable in the event in the 'save changes' button. This variable is set to 'Environ(Username)' upon clicking, or 'CurrentUser' (if you are using mdb and are using Access Security methods). You can also keep a method in the 'BeforeChanges' event of the form your editing, and send this information to an Audit Log table as well.

Related

How can I disable some mysql dataset for a user specified time frame in my webapp and restore it automatically [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
i am developing a web app to admininstrate a mysql database.
So far this work is making a good progress.
Now i need a feature to deactivate some datasets for a time frame the user can choose in the web app.
After deactivating: The dataset shouldn´t be active in the database, but the user should be able to restore the dataset anytime. (i will create a page: "Deactivated")
If the user doesnt restore the dataset. Then the dataset should be restored automatically when the specified time frame by the user is over.
How can i build this feature and disable some dataset for a time frame and restore it again after?
hope u understand and can help me ;)
i mean with dataset=rows in a database
You cannot solve this on the MySQL level. This database engine doesn't recognize data sets and time-framing them as you describe (As far as I know).
Because of that, you have to solve this on the application level.
I don't know what the structure of your database is, so let's say you store your data in the table named dataset.
1. part: Deactivated
I need a feature to deactivate some datasets
A potential solution here is to add a flag to the table dataset. And let's name it active. See MySQL Bool.
For this page
I will create a page: "Deactivated"
you can fetch data by this query
SELECT *
FROM dataset
WHERE active = false;
The consequence of this update (adding flag).
You should update all existing queries with this addition to the where clause: WHERE ... AND active = true.
For example, when you fetching data for a user with ID 10, the query is:
SELECT *
FROM dataset
WHERE user_id = 10
AND active = true;
2. part: Time frame
For this part, I propose to use another column in the dataset table - let's name it activation_date.
So, what is an idea here?
In this column, you store when that row should become active again.
For activation data, you need a job-scheduling framework. And each midnight, a background process executes this query.
UPDATE dataset
SET active = true
WHERE activation_date >= CURRENT_DATE();
Of course, you can use some more granular time; or activate your job at another time. It depends on the requirements.
Note for the job-scheduling framework. For Java, it could be Quartz. I am not sure which programming language you use; I guess, it has an equivalent tool like Quartz.

MS Access "Write Conflict" error when adding new field to record source

I want to preface this by saying I don't have any real programming background, I'm just trying to update an existing database at work.
We have an access database and I want to add an additional Y/N checkbox to an existing form. The form updates a SQL table. Currently the record source is a SQL statement.
I can go to the SQL table, add a new field and make it Yes/No data type. There are other Yes/No fields in the table and the default settings for the new field are identical to the others. I next go and update the linked table through External Data in the ribbon. I can go into the table in Access and see the new field - so far, so good.
Next, go to the form design view and form properties, go to the record source, update the SQL statement to include the new field. (I've also tried this thru query builder, same result.) From here, I start to get the error.
If I go back to form view and change any data in the form and hit the next record button or save button, I get the Write Conflict error. "This record has been changed by another user since you started editing it..." The 'Save Record' button is greyed out. I am the only person accessing the database or SQL server.
I've tried to finish building the new button and linking it to the new field in control source (that went fine), but it didn't make any difference. If I go in to edit the record source and remove the new field, everything works again (but of course, the new field isn't in the control source list, so isn't linked to the check box).
Any ideas? Thanks.
A strong contender for the reason for your problem is the form itself.
Most likely the form is setup with a specific query as the Record Source. Its not to say that that is inherently incorrect, but it makes adding new columns to the source significantly more difficult.
The problem would likely be solved if you just changed the Record Source to reference the table itself, rather than a query, if that is in fact how it is referenced.
If Ms Access tries to pull data from a table using a query through a form it will inherently Pessimistically Lock the table in question, making it unable to be modified. However, you can usually still modify the table through the query itself, but you would need to add the column changes into that query first.
I'm not quite sure if I am making sense here, but something like this (for a table called "Table1"):
In theory, if the form is the problem... then if you closed it and tried to make modifications to the table, then the changes should work when the form is closed.
Someone else fixed it for me, but from what I understand, it was a communication issue between SQL and Access. Something with the setting of the null value in SQL not being set the way that Access could understand.
We had the issue narrowed down. When the new field was added to the table, you couldn't change any info directly in the table, but you could with the form.
If you added the new field to the form's record source, you couldn't edit any info at all.
Thanks for everyone's input.

MS Access - Track changes made to existing table into another table (using table datasheet view - not form)

I want to be able to track any changes made to any of the fields in an existing table. The scenario is as follows:
the user opens the datasheet view for an existing table in MS Access 2007/2010
updates values in 2 fields and 5 rows (10 cells)
saves the table (overwrites it)
I want to be able to push the changes (10 changes/rows) to a new table and then be able to open it in datasheet view to refer to it. Is there a way I can do this in access without using form?
In 2010 and later you can use data macros, or what often other systems called table triggers.
You cannot in 2007.
Keep in mind that your use of the term “save table” is VERY wrong in the context here. In fact VERY wrong in the context of most databases. The user does not “save” the table.
You can ONLY edit ONE ROW at a time in a datasheet. When you move off that record then the ROW is saved (not the table). , and if you move off, then the record is saved.
In 2010 and later, you have use of table procedure code. This thus will allow one to use a table trigger.
So 2010 and later does support table triggers and store procedure code. But since your question in includes Access 2007, then my suggestion to use table triggers (called data macros) may not work unless you can restrict users to 2010 and beyond.
In the follow example, when a user updates a row, then a “audit” table is updated with the user information. The function fosusername() is in fact a VBA function. This code is called from the before change update event for the table.
Of course the problem here is the VERY basis of your question assumes that users save a table – they don’t, they edit + save “single” records, or a single row at a time. So figuring “out” how a user is done would certainly be a challenge. So while code can be run when the users edit data, having table code run “when” the user closes the table is not possible.
As the end of the day, it likely best you create a datasheet that looks just like the table, and then change a few settings to “lock down” and prevent the user from using tables directly.
As far as I know there is no solution for this without using a form. I do not know of events (like a change or dirty event) for the actual data tables.
In a form you could use the dirty property to make sure you fetch the data. You can make the form look like a datahseet with DoCmd.RunCommand acCmdDatasheetView or set the form in datasheet view on default.

Find a string and replace it the whole database [duplicate]

This question already has answers here:
Find and replace entire MySQL database
(12 answers)
Closed 9 years ago.
I have a wordpress website and I'm going to change it's URL. The problem is that when I search for its actual URL in the database, I have like 200 results.
I would like to search in the whole database for the actual url and replace it with the new one.
I know that if I have the exact table and exact column, I can do :
UPDATE
Table
SET
Column = Replace(Column, 'find value', 'replacement value')
But how can I generalize this code to my whole database ?
Thank You !
Perhaps not the best, one solution is to export the whole database, open the sql file in a text editor, perform the search-replace and importing again.

Microsoft Access : How can I get creation date of row?

I have an access database created from 7 years ago.
Unfortunately, tables didn't have time stamp column :(
Is there any way to be able to know the creation date for each row in a specific table ?
Unless you have a time stamp you created yourself, there is no way to find this information.
Is it possible that you have some old back-ups? That might help narrow it down.