Can anyone tell me why I'm getting run time error '3163' on the following line?
Here's the code listed before this:
Code:
If DCount("*", MedSelectQuery) > 0 Then
Here's the code listed before this:
Code:
Dim MedSelectQuery As String
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)
'query uses date created date
MedSelectQuery = "SELECT * " & _
"FROM [C:\Path\Database.accdb].tblMedData AS tblLaptop INNER JOIN [I:\Path\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));"
End If
MsgBox MedSelectQuery
'### Get path to current back end
myPath = Left(CurrentDb.name, InStr(CurrentDb.name, ".accdb") - 1) & "_be.accdb"
strFEPath = CurrentDb.name
If CurrentProject.Path <> strLocalPath Then 'not being ran from laptop or ran from wrong location -- don't allow sync
'not being ran from laptop or ran from wrong location -- don't allow sync
Me.Label0.Caption = "Synchronization not allowed from database in " & CurrentDb.name
dteLogDate = Now()
'### Use command to insert log record into table in same database
If strFEPath = strLocalPath Then
CurrentDb.Execute "insert into tblSyncLog (LoginID,SyncDate,syncAction) values ('" & strLogin & "', #" & dteLogDate & "#, '" & " FAILED TO SYNC FROM " & CurrentDb.name & "');"
Else
CurrentDb.Execute "insert into tblSyncLog (LoginID,SyncDate,syncAction) in strMasterFEUNC values ('" & strLogin & "', #" & dteLogDate & "#, '" & " FAILED TO SYNC FROM " & CurrentDb.name & "');"
End If
GoTo Exit_MedDataQuery_Click
Else
'correct path, continue sync
If DCount("*", MedSelectQuery) > 0 Then