RE: Sync-1 button

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Phil (Phil_at_discussions.microsoft.com)
Date: 12/30/04


Date: Thu, 30 Dec 2004 06:43:02 -0800

Try below, if you find a better why please post.

{You will need to have libs referenced to
Microsoft Access 9.0 Objects
Microsoft Jet and Replication 2.6 Objects
in back end}

Front-End Button:

Private Sub btnSync_Click()
    Sync_to_Hub
End Sub

Front-End Module:

Public Sub Sync_to_Hub()

    On Error GoTo Sync_to_Hub_Error
    
    'Inform the user that the Sync is taking place
    DoCmd.OpenForm "frmMessages" 'you will need to create this form or
display a message in the status bar
    Form_frmMessages.txtMessage = "Synchronizing with the Hub database on
the H: Drive, Please wait..."
    Form_frmMessages.Repaint
         If Dir("C:\Program Files\Microsoft Office
2000\Office\MSACCESS.EXE") <> "" Then
            varReturn = Shell("C:\Program Files\Microsoft Office
2000\Office\MSACCESS.EXE /runtime " & Chr$(34) & "C:\Program
Files\AccountingLink2000\AccountingLink2000_Data.mdb" & Chr$(34) & " /wrkgrp
" & Chr$(34) & "H:\Micro\AccountingLink2000\AccountingLink2000.mdw" &
Chr$(34) & " /user " & Chr$(34) & "useranme" & Chr$(34) & " /pwd " & Chr$(34)
& "password" & Chr$(34), vbHide)
        Else
            'MS-Access Run-time could be installed in another location try...
            varReturn = Shell("C:\Program Files\Microsoft
Office\Office\MSACCESS.EXE /runtime " & Chr$(34) & "C:\Program
Files\AccountingLink2000\AccountingLink2000_Data.mdb" & Chr$(34) & " /wrkgrp
" & Chr$(34) & "H:\Micro\AccountingLink2000\AccountingLink2000.mdw" &
Chr$(34) & " /user " & Chr$(34) & "username" & Chr$(34) & " /pwd " & Chr$(34)
& "pasword" & Chr$(34), vbHide)
        End If
    
    DoCmd.Close acForm, "frmMessages"
    
Sync_to_Hub_Exit:
    Exit Sub

Sync_to_Hub_Error:
    MsgBox "Front End - Error: " & Err.Description & " (" & Err.Number & ")"
    Exit Sub
    
End Sub

Back-End
autoexec macro 1 entry:
RunCommand Sync()

Back-End Module Sync:

Public Function Sync()

    On Error GoTo Sync_Error
    
    Dim rpl As JRO.Replica
    Set rpl = New JRO.Replica
    Set rpl.ActiveConnection = CurrentProject.Connection
    rpl.Synchronize "H:\Micro\AccountingLink2000\Replica of
AccountingLink2000_Data.mdb", jrSyncTypeImpExp, jrSyncModeDirect
       
    'MsgBox "Back End Database Synchronization Complete", vbInformation +
vbApplicationModal, "AccountingLink 2000 Data"
        
Sync_Exit:
    Quit
    Exit Function

Sync_Error:

    MsgBox "Back End - Error: " & Err.Description & " (" & Err.Number & ")"
    Exit Function

End Function

"Paula" wrote:

> Hi,
> is it posible to create a button that does al the Replication/Syncronize
> Now! all by putting code in ?
> I do not want to give people access to menus but they must be able to syncr.
> their offline computers with the main server by pressing a button.
> Cheers
> P
>


Quantcast