Results 1 to 8 of 8
  1. #1
    jerem is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    88

    Synchronize Sharepoint Lists

    How to replicate in VBA exactly what the "Synchronize" button in External Data tab of the ribbon does? Is there a Docmd something?

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,863
    On a scale from 1 to 10 my knowledge of Share Point is -3. However I did find these

    acCmdSynchronize
    acCmdSynchronizeNow
    acCmdSyncWebApplication

    Should be able to get a hold of them like this.
    Application.RunCommand acCmdSynchronize

    Or maybe if you need to focus on an object for the Synchronize to work, set focus and then
    Docmd.RunCommand acCmdSynchronize

    http://msdn.microsoft.com/en-us/libr...ffice.14).aspx


    .

  3. #3
    jerem is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    88
    Thanks ItsMe!

    I have managed to get it to work in Ms Acccess with your hint and using this: http://www.utteraccess.com/forum/lof.../t1945982.html

    but it doesn't work in a RunTime environment. I suspect that is because the code requires to have the Navigation Pane open, which does not exist in RT.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,863
    The Navigation Pane does exist in RT. Perhaps you opt to have the Navigation Pane hidden and this is the issue. Things that are not available in RT would be the Debugger and Saving design changes to Forms, etc. Of course, those (Synch) commands may, in fact, not be available in RT.

    Something that comes to mind is hiding toolbars in older versions of Access. If you hide a specific toolbar via VBA and then try to run one of the tools in said toolbar, the action of running the tool will fail. I have not experienced this issue yet with hiding the Ribbon, but it may be an issue with the Ribbon too.

    Can you post the code you are using to Re-synch? I will take a look at it for stuff that is obvious to me, that will not work in RT.

  5. #5
    jerem is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    88
    Here is the code. The reason why it unhides the navigation pane is that apparently it is needed for the DoCmd.AcCmdSynchronize to work. However if you do it by pressing the command button in the Ribbon, Access does not seem to unhide the navigation pane. The original code comes from there: http://www.utteraccess.com/forum/lof.../t1945982.html
    Code:
    Private Sub txtSync_Click()
        If Online Then
            TempVars.Add "AlertMessage", "You're already working online, there is no need to synchronize"
            DoCmd.OpenForm "OkAlert", , , , , acDialog
            Exit Sub
        End If
        TempVars.Add "YesNoMessage", "Do you want to synchronize now?"
        DoCmd.OpenForm "YesNoAlert", acNormal, , , , acDialog
        If TempVars("YesNoResponse").Value = False Then
            Exit Sub
        Else
            Call SyncWithSharePoint
        End If
    End Sub
    
    Public Function SyncWithSharePoint( _
          Optional FormToOpenWhenDone As String, _
          Optional FilterName As String, _
          Optional WhereCondition As String, _
          Optional DataMode As AcFormOpenDataMode = AcFormOpenDataMode.acFormEdit, _
          Optional OpenArgs As String) As Boolean
    
    
        FormToOpenWhenDone = "Main"
        On Error GoTo Panic
        CloseAllForms
        PauseWithEvents 3
    
    
        DoCmd.Echo False
        DoCmd.SelectObject acTable, , True
        DoCmd.Minimize
        DoEvents
        
        DoCmd.RunCommand acCmdSynchronize
        DoCmd.Hourglass True
        DoCmd.NavigateTo "acNavigationCategoryObjectType"
        DoCmd.RunCommand acCmdWindowHide
    
    
    SeeYa:
        If Not IsMissing(FormToOpenWhenDone) Then
            If FormToOpenWhenDone <> "" Then
                PauseWithEvents 3
                DoCmd.OpenForm FormToOpenWhenDone, acNormal, FilterName, WhereCondition, DataMode, acWindowNormal, OpenArgs
            End If
        End If
        DoCmd.Hourglass False
        DoCmd.Echo True
        Exit Function
        
    Panic:
        MsgBox "Unable to sync, please check your network connection and try again."
        Resume SeeYa
        MsgBox Err.Description
        Resume
    End Function
    Public Function PauseWithEvents(seconds As Single)
        Dim timerStart As Single
        timerStart = Timer
        Do While timerStart + seconds > Timer
            DoEvents
            DoEvents
            Sleep (55)
        Loop
    End Function
    
    
    Public Function CloseAllForms() As Boolean
        Dim frm As Form
    
    
        For Each frm In Forms
            DoCmd.Close acForm, frm.Name, acSavePrompt
        Next frm
    End Function
    
    
    Public Property Get Online() As Boolean
        Online = CurrentDb.Properties("HasOfflineLists") = 70 ' 70 == 'F' for 'False'.
    End Property
    
    
    Public Property Get Offline() As Boolean
        Offline = CurrentDb.Properties("HasOfflineLists") = 84 ' 84 == 'T' for 'True'.
    End Property

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,863
    If someone thoroughly tested the Navigation Pane thing, then that is probably the issue.



    Quote Originally Posted by jerem View Post
    ...Access does not seem to unhide the navigation pane...
    I am going to guess that collapsing and expanding are different than using Options to Hide.

    I believe DoCmd.Minimize could cause issues if you are not running Overlapping Windows. Although, I believe I use .Maximize in RT while using Tabbed Windows so maybe it is OK. If it works while testing, should work in RT....

    I have never tried to do anything like this outside of a Form's or Report's module. Could cause issues if tried within a Class Module or Standard Module.
    Do While timerStart + seconds > Timer

    But, if it is working in a full version of Access it should work in RT

    The only other thing would be
    Online = CurrentDb.Properties("HasOfflineLists") = 70

    Not familiar with Lists and Offline. Can you cause your app to be Offline in RT? Perhaps you can isolate and test this.

  7. #7
    jerem is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    88
    I have tried several things but I could not find a way to force offline in RT. It does go offline and synchronize very well by itself but there is no way I know of to take the application offline manually.

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,863
    It has been a while since I read through this thread. I believe the issue is around the nav pane being expanded or not. This is the claim of the other poster in the other thread. If this is true (the nav pane needs to be open in order to focus on an object like a table or query), then whether the code depends on RT or it does not depend on RT, is not relevant. Test with the Nav Pane open.

    You and I may have a different view on what RT is. You do not get to choose whether RT is used or not (aside from choosing what code, tools, and or processes to implement within the app). The exception is when you use a machine that does not have a full version of Access installed and it only has the Run Time version of Access installed. Running apps from a machine like this will have no choice but to use RT only. This is true because there is not an option to use Design Time or Debug Time.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 0
    Last Post: 03-24-2014, 09:35 AM
  2. Synchronize multiple comboboxes
    By phyllo in forum Forms
    Replies: 1
    Last Post: 05-01-2012, 01:49 PM
  3. Syncronizing Linked Lists from Sharepoint to Access
    By se7en9057 in forum Import/Export Data
    Replies: 0
    Last Post: 11-02-2011, 02:04 PM
  4. Sharepoint Lists vs Web database as backend
    By is49460 in forum SharePoint
    Replies: 1
    Last Post: 10-28-2011, 04:27 PM
  5. Sync Fails with Sharepoint Lists
    By is49460 in forum SharePoint
    Replies: 0
    Last Post: 01-16-2011, 01:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums - Senior Forums