I'm using a latebinding method to update a table via a user form, but keep getting an error message saying "Syntax error in From clause." I'm not sure what it is that I'm doing wrong here. Below is my code. Any help would greatly appreciated.
Const adUseServer = 2
Const adOpenDynamic = 2
Const adLockOptimistic = 3
Const adCmdTable = 2
Sub UpdateRoutineTable()
Dim rst As Object
Dim cn As Object
Dim d As Double
Dim x As Double
Set rst = CreateObject("ADODB.Recordset")
Set cn = CreateObject("ADODB.Connection")
If Routine.Analyst = "" Or Routine.Tasks = "" Or _
Routine.hrs = "" Or Routine.Mins = "" Or Routine.DateCompleted = "" Then
MsgBox "Please populate all fields and try again.", vbOKOnly, "Missing Fields"
Exit Sub
Else
d = Routine.hrs + (Routine.Mins / 60)
x = Routine.rptID
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = tmtPath
.Open
End With
rst.CursorLocation = 2
rst.Open Source:="Select * From RoutineTable WHERE Reporting_ID=" & x, _
ActiveConnection:=cn, _
CursorType:=2, _
LockType:=3, _
Options:=2
With rst
!Due_Date = Routine.dueDate2
!Date_Updated = Routine.DateCompleted
!Date_Entered = Now
!Durration = d
!UpdatedBy = Application.UserName
.Update
End With
End If
rst.Close
cn.Close
Set rst = Nothing
Set cn = Nothing
End Sub
Const adUseServer = 2
Const adOpenDynamic = 2
Const adLockOptimistic = 3
Const adCmdTable = 2
Sub UpdateRoutineTable()
Dim rst As Object
Dim cn As Object
Dim d As Double
Dim x As Double
Set rst = CreateObject("ADODB.Recordset")
Set cn = CreateObject("ADODB.Connection")
If Routine.Analyst = "" Or Routine.Tasks = "" Or _
Routine.hrs = "" Or Routine.Mins = "" Or Routine.DateCompleted = "" Then
MsgBox "Please populate all fields and try again.", vbOKOnly, "Missing Fields"
Exit Sub
Else
d = Routine.hrs + (Routine.Mins / 60)
x = Routine.rptID
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = tmtPath
.Open
End With
rst.CursorLocation = 2
rst.Open Source:="Select * From RoutineTable WHERE Reporting_ID=" & x, _
ActiveConnection:=cn, _
CursorType:=2, _
LockType:=3, _
Options:=2
With rst
!Due_Date = Routine.dueDate2
!Date_Updated = Routine.DateCompleted
!Date_Entered = Now
!Durration = d
!UpdatedBy = Application.UserName
.Update
End With
End If
rst.Close
cn.Close
Set rst = Nothing
Set cn = Nothing
End Sub