Can someone tell me why I'm getting a run-time error on the line below? I suspect it has something to do with the SQL query I have defined in the variable?
Line causing run-time error:
Content of MedSelectQuery variable:
FileCreatedDate variable code:
Line causing run-time error:
Code:
Set rs = db.OpenRecordset(MedSelectQuery, dbOpenDynaset)
Content of MedSelectQuery variable:
Code:
strLocalBE = Left(CurrentProject.FullName, Len(CurrentProject.FullName) - 6) & "_be.accdb"
MedSelectQuery = "SELECT * " & _
"FROM [C:\Database.accdb].tblMedData AS tblLaptop
INNER JOIN [I:\Database_be.accdb].tblMedData " & _
"AS tblServer ON tblLaptop.InvNo = tblServer.InvNo " & _
"WHERE ((tblLaptop.DateChanged)>=(" & FileCreatedDate & "))
And ((tblServer.DateChanged)>=(" & FileCreatedDate & ")) And " & _
"(((tblLaptop.DetailsChanged)=True And (tblServer.DetailsChanged)=True
And (tblLaptop.Ratio)<>tblServer!Ratio)) " & _
"Or (((tblLaptop.Duration)<>tblServer!Duration))
Or (((tblLaptop.Withdrawal)<>tblServer!Withdrawal))
Or (((tblLaptop.WaterOrInject)<>tblServer!WaterOrInject))" & _
"Or (((tblLaptop.ChangedBy)<>tblServer!ChangedBy))
Or (((tblLaptop.Deleted)<>tblServer!Deleted));"
FileCreatedDate variable code:
Code:
Dim fso, f As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(strLocalBE)
Dim FileCreatedDate As Date
If f <> "" Then
FileCreatedDate = f.DateCreated
Else
MsgBox "Missing data in path file -- unable to synchronize. Contact IS.", vbCritical, "Synchronization Failed"
Me.Label0.Caption = "Synchronization Failed -- Missing File Paths. Contact IS!"
Exit Sub
End If
Set fso = Nothing
Set f = Nothing
..............
FileCreatedDate = FileDateTime(strLocalBE)