![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have an access form where I capture a payroll code (PayrollNo). I want to be able to click the button and have access run a stored procedure in SQL Server to update the payroll field with the code in the access form, where the EmpNo (id) = the EmpNo on the table with the list of current employee's payroll. My code did not work--it didn't update. What did I do wrong? Thanks so much! Here is the VBA code on the button: Private Sub UpdPRNo_Click() Dim mydb As DAO.Database Dim qdf As DAO.QueryDef Set mydb = CurrentDb Set qdf = mydb.CreateQueryDef("qryUpdatePayroll") With qdf .Connect = "ODBC;DSN=servername;UID=username;DATABASE=databas ename;Trusted_Connection=Yes" .SQL = "dbo.UpdateHRPayroll '" & Me.PayrollNo & "';" .ReturnsRecords = False .Execute .Close End With CurrentDb.QueryDefs.Delete (qdf.Name) End Sub This is the Stored procedure CREATE PROCEDURE [dbo].[UpdateHRPayroll] (@PayrollNo NVARCHAR(10)) AS BEGIN ALTER TABLE dbo.Employees Disable TRIGGER tr_TIMESTAMP_UPDATE Update dbo.Employees SET dbo.Employees.Payperiod = @PayrollNo FROM dbo.Employees INNER JOIN dbo.Temp_Payroll ON dbo.Employees.EmpNo = dbo.TempPayroll.EmpNo ALTER TABLE dbo.Employees Truncate Table dbo.Temp_Payroll END |
#3
| |||
| |||
|
|
I have an access form where I capture a payroll code (PayrollNo). I want to be able to click the button and have access run a stored procedure in SQL Server to update the payroll field with the code in the access form, where the EmpNo (id) = the EmpNo on the table with the list of current employee's payroll. My code did not work--it didn't update. What did I do wrong? Thanks so much! Here is the VBA code on the button: Private Sub UpdPRNo_Click() Dim mydb As DAO.Database Dim qdf As DAO.QueryDef Set mydb = CurrentDb Set qdf = mydb.CreateQueryDef("qryUpdatePayroll") With qdf .Connect = "ODBC;DSN=servername;UID=username;DATABASE=databas ename;Trusted_Connection=Y |
|
.SQL = "dbo.UpdateHRPayroll '" & Me.PayrollNo & "';" |
#4
| |||
| |||
|
|
I have an access form where I capture a payroll code (PayrollNo). I want to be able to click the button and have access run a stored procedure in SQL Server to update the payroll field with the code in the access form, where the EmpNo (id) = the EmpNo on the table with the list of current employee's payroll. My code did not work--it didn't update. What did I do wrong? Thanks so much! Here is the VBA code on the button: Private Sub UpdPRNo_Click() Dim mydb As DAO.Database Dim qdf As DAO.QueryDef Set mydb = CurrentDb Set qdf = mydb.CreateQueryDef("qryUpdatePayroll") With qdf .Connect = "ODBC;DSN=servername;UID=username;DATABASE=databas ename;Trusted_Connection=Y |
|
.SQL = "dbo.UpdateHRPayroll '" & Me.PayrollNo & "';" |
![]() |
| Thread Tools | |
| Display Modes | |
| |