How to replicate in VBA exactly what the "Synchronize" button in External Data tab of the ribbon does? Is there a Docmd something?
How to replicate in VBA exactly what the "Synchronize" button in External Data tab of the ribbon does? Is there a Docmd something?
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
.
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.
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.
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
If someone thoroughly tested the Navigation Pane thing, then that is probably the issue.
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.
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.
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.