Run time error '3163'?

candyA25

New member
Local time
Today, 16:08
Joined
Jun 26, 2013
Messages
9
Can anyone tell me why I'm getting run time error '3163' on the following line?

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
 
I'm pretty sure that DCount() will only work using a table or saved query, don't think it will work with SQL. You could open a recordset on the SQL and get the count from that (don't forget a MoveLast).
 
I got a 3163 error too. I fixed it by running "compact and repair" on the front end and back end databases.
 

Users who are viewing this thread

Back
Top Bottom