SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Update Field to current logged in user ID with new record command button


Update Field to current logged in user ID with new record command button

Author
Message
kwoznica
kwoznica
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1145 Visits: 481
Also here is the complete table definition.


USE [GKHumanResource]
GO

/****** Object: Table [dbo].[HRCaseData] Script Date: 8/7/2013 3:59:59 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[HRCaseData](
[Id] [int] IDENTITY(100,1) NOT NULL,
[CaseDate] [date] NOT NULL,
[Customer] [varchar](50) NOT NULL,
[HrRepId] [varchar](50) NOT NULL,
[Category] [int] NOT NULL,
[CaseDescription] [varchar](30) NOT NULL,
[CaseStatus] [bit] NOT NULL,
[ClosedDate] [date] NULL,
[Resolution] [varchar](1000) NULL,
[DepartmentID] [smallint] NOT NULL,
CONSTRAINT [PK_ID_Customer_Category] PRIMARY KEY CLUSTERED
(
[Id] ASC,
[Customer] ASC,
[Category] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[HRCaseData] ADD CONSTRAINT [DF_HRCaseData_HrRepId] DEFAULT (suser_sname()) FOR [HrRepId]
GO

ALTER TABLE [dbo].[HRCaseData] ADD DEFAULT ((7)) FOR [DepartmentID]
GO

ALTER TABLE [dbo].[HRCaseData] WITH CHECK ADD CONSTRAINT [FK_Category_CatType] FOREIGN KEY([Category])
REFERENCES [dbo].[HRCategory] ([ID])
GO

ALTER TABLE [dbo].[HRCaseData] CHECK CONSTRAINT [FK_Category_CatType]
GO

ALTER TABLE [dbo].[HRCaseData] WITH CHECK ADD CONSTRAINT [FK_Department] FOREIGN KEY([DepartmentID])
REFERENCES [dbo].[HRDepartment] ([DepartmentID])
GO

ALTER TABLE [dbo].[HRCaseData] CHECK CONSTRAINT [FK_Department]
GO




WendellB
WendellB
SSCrazy
SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)

Group: General Forum Members
Points: 2114 Visits: 1832
There should not be any difference based on SQL Server version or Access version. This technique is dependant only on SQL Server, and we have similar tables that work just fine on both versions you mention.

On permissions, we normally give each user dbowner on the database so that we don't have to set permissions on all of the objects - as in general our users should be able to update all the tables. (We do restrict users by presenting the data in forms and do not give them access to the tables.)

Just a hunch, but by chance are they using an Access form to add records that has a different default value set for that field? That seems to me to be the most logical explanation for the behavior you are seeing. To test that you could try adding a record to the table directly without using an Access form. Another more remote possibility is that there is an issue with the UserName in SQL Server - is this Integrated Security or SQL Server Security? Also it would help to know if the field is truly a Null, a series of blank characters, or an empty text string.

Wendell
Colorful Colorado
You can't see the view if you don't climb the mountain!
kwoznica
kwoznica
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1145 Visits: 481
Sorry for the false alarm. It was me being a fool. When I added the ODBC connection from access I was importing the data instead of choosing linking. Once I changed that about 3 hours of banging my head against the wall was all due to a simple over sight.

It is working very well now. Thanks for your help.
sumanth.pathuri
sumanth.pathuri
SSC Rookie
SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)

Group: General Forum Members
Points: 43 Visits: 12
How can we capture if someone edits a record without using a trigger. We need a column in the same table. Can you please help me with this.
Lowell
Lowell
SSC Guru
SSC Guru (71K reputation)SSC Guru (71K reputation)SSC Guru (71K reputation)SSC Guru (71K reputation)SSC Guru (71K reputation)SSC Guru (71K reputation)SSC Guru (71K reputation)SSC Guru (71K reputation)

Group: General Forum Members
Points: 71802 Visits: 40942
sumanth.pathuri (1/11/2017)
How can we capture if someone edits a record without using a trigger. We need a column in the same table. Can you please help me with this.


you should start a new thread to get the best help, since this thread is four years old or so. also, the forum is related to Access, but you really mean SQL, right?

so are you sure you want to paint yourself in a corner with a rule that says absolutely, positively, without a trigger AND you need whodunnit information?

a trigger is the best way to handle that requirement, i would say.

For data changes, you can use SQL Temporal Tables, Change Data Capture to track what specific data changed, Change Tracking to capture which data changed, but neither has who did it information.

For whodunnit changes, SQL Audit or an Extended event has who changed the data, but not the details of which specific data was changed.

I'm under the impression that the only place for both data and user info is at the trigger level, unless someone can correct me on my conceptions/misconceptions.

Lowell
--help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!
WendellB
WendellB
SSCrazy
SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)

Group: General Forum Members
Points: 2114 Visits: 1832
sumanth.pathuri (1/11/2017)
How can we capture if someone edits a record without using a trigger. We need a column in the same table. Can you please help me with this.
As this is a rather old thread, are you working in the same situation as the original poster? That is, are you working with ODBC linked tables in an Access front-end? Or are you working with an Access ADP that connects directly to SQL Server? Also the versions may be important. In the first case, you can create VBA procedures that are initiated by the OnChange event of the form that update a last changed field, assuming that your form is bound to a table source. However if you allow editing at the table level, and at least some users will probably have that capability, then using triggers is the only effective way we have found to track who and when a record was last changed.

Wendell
Colorful Colorado
You can't see the view if you don't climb the mountain!
Welsh Corgi
Welsh Corgi
One Orange Chip
One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)

Group: General Forum Members
Points: 26966 Visits: 4895
Hi,

There is a type of a Microsoft Project where you do not use linked table or connect via VBA Code.

You can point you stored procedures to the queries..

It has been a long time since I did this but I would appreciate any help.

Thank you.

For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
J Livingston SQL
J Livingston SQL
SSChampion
SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)

Group: General Forum Members
Points: 12201 Visits: 37557
Welsh Corgi - Sunday, April 23, 2017 8:26 AM
Hi,

There is a type of a Microsoft Project where you do not use linked table or connect via VBA Code.

You can point you stored procedures to the queries..

It has been a long time since I did this but I would appreciate any help.

Thank you.

is this a new question? suggest starting a new thread if it is


________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day

Welsh Corgi
Welsh Corgi
One Orange Chip
One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)

Group: General Forum Members
Points: 26966 Visits: 4895
J Livingston SQL - Sunday, April 23, 2017 10:10 AM
Welsh Corgi - Sunday, April 23, 2017 8:26 AM
Hi,

There is a type of a Microsoft Project where you do not use linked table or connect via VBA Code.

You can point you stored procedures to the queries..

It has been a long time since I did this but I would appreciate any help.

Thank you.

is this a new question? suggest starting a new thread if it is


Sorry but I though I was opening a new post.

For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Welsh Corgi
Welsh Corgi
One Orange Chip
One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)

Group: General Forum Members
Points: 26966 Visits: 4895
WendellB - Wednesday, January 11, 2017 11:40 AM
sumanth.pathuri (1/11/2017)
How can we capture if someone edits a record without using a trigger. We need a column in the same table. Can you please help me with this.
As this is a rather old thread, are you working in the same situation as the original poster? That is, are you working with ODBC linked tables in an Access front-end? Or are you working with an Access ADP that connects directly to SQL Server? Also the versions may be important. In the first case, you can create VBA procedures that are initiated by the OnChange event of the form that update a last changed field, assuming that your form is bound to a table source. However if you allow editing at the table level, and at least some users will probably have that capability, then using triggers is the only effective way we have found to track who and when a record was last changed.


Does Microsoft Access still suport ADP?

For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search