MS Access, How can I detect new insert vs update inside trigger macros? - ms-access-2010

MS Office 265 ProPlus, Access 2007 - 2016
While defining a "Before Update" macro(?) on a table, I'd like to be able to detect when this is an update to an existing record vs inserting a new record.
I know about and have used the "Old" context tag/prefix in other cases. In this case I guess "Old" wouldn't exist or be undefined if this is an insert. Is there a way to detect that? Is there some other way?
Thanks for any help.

Are you referring to Before Change table event?
Use the IsInsert property to determine whether the Before Change event was triggered by a new record being created or a change to an existing record

Related

Write Conflict error in MS Access 2010 when i try to assign a record source

I have SQL Server 2008 R2 linked tables in my MS Access 2010.
I have many forms in this MS Access database. Few of my forms gets Write Conflict error when I try to assign it to a SQL statement as record source after I have updated very same record by SQL statement (or assign some values on form programmatically and refreshed the form in module) as I have general function being called every time I enter certain text on one of the field on form and it gets updated some of the forms fields value programmatically.
I have a TIMESTAMP column in my table in SQL Server.
So after updating the fields on the forms, when I try to assign a new record like
Me.Recordsouce = sqlstring , I get a "write conflict" error.
I tried to set on button click before I assign a recordsource
Refresh
Docmd.RunCommand AcCmdSaveRecord
But they all throw the same "Write Conflict" error and asking me to drop changes.
Please help
Many thanks,

Sage CRM - Capture entity event update?

Can i alter/intercept the event when updating an entity?
For example, for when i update the company entity?
The idea is to delete somehting in the BBDD after the entity is updated
You can use Table Scripts to run functions when a record is inserted, after a record is inserted, when a record is updated, or when a record is deleted.
Table Scripts use JavaScript, but have access to the server-side functions (such as FindRecord, SQL statements, etc).
So, you can add a Table Script to the Entity to delete a record via a SQL statement when a record is updated.
It's difficult to give you an example without knowing exactly what you're trying to do though.
Six Ticks Support

How to find if file has been imported in Access database or created within it?

In my access database there is a dataset which I need to know how it has been created. I tried to backtrack and reached to a table for which I am not able to find any source data. I am pretty much sure that it has been imported from some where. I checked in "View" option there is not "SQL" view for that table. It only has "Datasheet" view and "Design View".
In access database is there any way to check that whether a file has been imported or has been created using SQL query within access database? Is there any "flag" raised or something like that?
No. Once data is persisted in a table, that's it.
If you need further info, you can have a Timestamp field with a default value of:
Now()
or, if a higher resolution than one second is needed:
Date() + Timer() / 86400
or another custom field where you record session info as you like during the import or creation of data.

Razor MVC - Object Edit Field Change Log

Users modify a DB object in an edit form that I have, pretty straight forward.
I need to implement a 'change log' on this object. I need to record which fields where changed and what they were before and after. I'm using Razor MVC.
I've done this by writing triggers for the table on update/delete. On update/delete of a record, the trigger pushes the record to a History table, in a History database. This creates the change log. Then you would just need to display it; to identify the change would require evaluating each and every field.
There's nothing already built that wold do this for you that I know of.

Sql Database Server

Hi i have a sql database server runnin on my desktop. I want to create an asp.net application to detect when new data has been inserted into the database. Is there a command in visual studio to detect when theres new data right away?
Use the timestamp datatype on each column. This will stay identical until a change is made to any column in that row. If you combine this with the rowcount you can be certain if anything has changed in your database. You would need to cache the current timestamps and row count and compare them with the results of a query, you can then find out if there is a change.
So in your answer to:
Is there a command in visual studio to
detect when theres new data right
away?
Yes there is, although its not a command is the timestamp function (not to be confused with anything to do with the time)
Perhaps you need to provide more details to your scenario since constant querying of the database might not be the best way forward.
You can get a row count of your dataset and create a application
IN VB
Dim i as Integer
i=dataset.tables("table").rows.count
in sql backed return a count of a table and create a ASP.Net website to get the count and when count change alerts you
It may be heavier duty than you are looking for, but SQL Notification Services will do what you want. Essentially you execute a query and tell notification services you want to be notified whenever re-running that query would produce different results.
if you are using caching you can make it dependent on sql.
or you can fire email using sql trigger so when ever trigger get fired you will receive an email.
otherwise you will have to check your db again and again for any changes.
if you can provide more details about exact situation , we can provide more specific solution
You can create a webservice and call it using javascript.
here you can find sample how to call webservice using javascript:
function CallWebservice()
{
myWebService.isPrimeNumberWebService.callService(isPrimeNumberResult, "IsPrime",
testValue.value);
setTimeout("CallWebservice()",100);//here set time according to your requirement
}
For timer in javascript:
http://dotnetacademy.blogspot.com/2010/09/timer-in-javascript.html
For webservice in javaScript:
http://www.webreference.com/js/tips/020715.html
How to call webservice in JavaScript for FireFox 3.0

Resources