Code to Work Offline

Oh, you don't want the ribbon! So how does it behave when it's clicked? Does it work go offline and does it look like the db gets re-loaded?

The Offline code seems to be that button but I think that Access is doing more when the button is clicked.

Here's an update:
Code:
Public Function ToggleOfflineMain(AccAppToToggle As Access.Application, _
                                  AccAppPath As String)
    
    With AccAppToToggle
        .CloseCurrentDatabase
        .Quit
    End With
    
    Set AccAppToToggle = Nothing
    Set AccAppToToggle = New Access.Application
    
    With AccAppToToggle
        .OpenCurrentDatabase AccAppPath
        .RunCommand acCmdToggleOffline
        .Visible = True
    End With
    
    Set AccAppToToggle = Nothing
    
    Application.Quit
End Function
I don't have Sharepoint so it makes it harder to resolve.
 
Hi

No I just wanted my own cmd button on my nav form to toggle online status.

When i click the built in button in the ribbon it immediately starts connecting or disconnecting sharepoint files then shows as online or offline with sharepoint

button works really well just a pain its not within my actual database form.

tried new code and again same message that i dont have exclusive access


thanks
 
You said that post #14 runs, can you re-test that again using the same steps as well.

Also, before you run any tests, are you making sure that it's online?
 
I have re run that post 14 test from a cmd button on a single form in the new db and it works ok toggles between online and offline the main database.

Yes always start with main db online.

thanks
 
I think see the problem. Updated code... you know what to do with them:

Main db
Code:
    Dim accApp As Access.Application
    
    Const PATH_TOGGLE_DB As String = "[COLOR="blue"]Path to the new db[/COLOR]"
    
    Set accApp = New Access.Application
    
    With accApp
        .OpenCurrentDatabase PATH_TOGGLE_DB
    End With
    
    Set accApp = Nothing

New db:
Code:
Public Function ToggleOfflineMain()
    Dim accApp  As Access.Application
    
    Const PATH_MAIN_DB As String = "[COLOR="Blue"]Path to main db[/COLOR]"
    
    DoEvents
    
    Set accApp = GetObject(PATH_MAIN_DB)
    With accApp
        '.DoCmd.RunCommand acCmdSynchronize
        .Quit
    End With
    
    Set accApp = Nothing
    Set accApp = New Access.Application
    
    With accApp
        .OpenCurrentDatabase PATH_MAIN_DB
        .Visible = True
        .RunCommand acCmdToggleOffline
    End With
    
    Set accApp = Nothing
    
    Application.Quit
End Function
Create an AutoExec macro in the new db that will run the ToggleOfflineMain() function.

Remember to Debug > Compile and save.
 
Just a little help in summary

so main db had a cmd button with on click event with code updated below

new db has the module with updated code below

then i have to create a macro in the new db autoexec (not sure how to create a macro to the toggle function only ever use whats available in the list of macro commands)

if that makes sense

is that correct or have i lost the plot
 
sorry and how am I trying to run this now, by clicking the cmd button on main db or opening the new db with the autoexec?

thanks
 
Click on the Show All Actions button on the ribbon, search for the RunCode action and use that. And test it.
 
Thanks

still get message saying I dont have exclusive access, sharepoint lists cannot be taken offline all db killed and pc restarted.

Have tested the built in button on the ribbon and that lets me go offline and disconnect sharepoint lists no problem

the only time ive been able to do it was when we had the code on the button on the form in the new db if you can remember.

Thanks

Jon
 
Are you working on a private sharepoint platform? If you are, and you're comfortable with it, can you create a linked list for me and provide me with the credentials (by PM) so that I can log-in to it and then I'll be able to provide some definitive code.
 
Little late getting to the party here. I was trying to do this exact very thing last week.

Was there any resolution to this issue?
 

Users who are viewing this thread

Back
Top Bottom