waseem0888
Member
- Local time
- Today, 00:29
- Joined
- Jul 25, 2020
- Messages
- 51
Hi,
I have linked Access frontend to SQL server backend through ODBC DSN file my table is having primary key and I am able to update record directly into the table without any issue but when I am trying to update in VBA I am getting below message.
Runtime error 3157: ODBC Update on a linked table " Table Name" failed -
[Microsoft][ODBC SQL Server Driver]Timeout expired(#0)
I have tried below different ways to update records but got the same error.
1st
Dim strSQL As String
strSQL = "UPDATE RFIA_Register SET Current = 'No' WHERE ID =" & Me.draftNo & ""
Debug.Print strSQL
CurrentDb.Execute strSQL, dbSeeChanges
2nd
Dim strSQL As String
strSQL = "UPDATE RFIA_Register SET Current = 'No' WHERE ID =" & Me.draftNo & ""
DoCmd.RunSQL strSQL
3rd
Dim db As DAO.Database, rec As DAO.Recordset
Dim strSQL As String
strQruery = "SELECT Current FROM RFIA_Register WHERE ID=" & Me.draftNo & ""
Set db = CurrentDb()
Set rec = db.OpenRecordset(strQruery, dbOpenDynaset, dbSeeChanges)
With rec
.MoveFirst
Do
rec.Edit
rec!Current = "No"
rec.Update
.MoveNext
Loop Until .EOF
.Close
End With
db.Close
Set rec = Nothing
Set db = Nothing
I have linked Access frontend to SQL server backend through ODBC DSN file my table is having primary key and I am able to update record directly into the table without any issue but when I am trying to update in VBA I am getting below message.
Runtime error 3157: ODBC Update on a linked table " Table Name" failed -
[Microsoft][ODBC SQL Server Driver]Timeout expired(#0)
I have tried below different ways to update records but got the same error.
1st
Dim strSQL As String
strSQL = "UPDATE RFIA_Register SET Current = 'No' WHERE ID =" & Me.draftNo & ""
Debug.Print strSQL
CurrentDb.Execute strSQL, dbSeeChanges
2nd
Dim strSQL As String
strSQL = "UPDATE RFIA_Register SET Current = 'No' WHERE ID =" & Me.draftNo & ""
DoCmd.RunSQL strSQL
3rd
Dim db As DAO.Database, rec As DAO.Recordset
Dim strSQL As String
strQruery = "SELECT Current FROM RFIA_Register WHERE ID=" & Me.draftNo & ""
Set db = CurrentDb()
Set rec = db.OpenRecordset(strQruery, dbOpenDynaset, dbSeeChanges)
With rec
.MoveFirst
Do
rec.Edit
rec!Current = "No"
rec.Update
.MoveNext
Loop Until .EOF
.Close
End With
db.Close
Set rec = Nothing
Set db = Nothing