Hallo,
wenn eine Verbindung ueber ein Netzwerk zwischen beiden Dateien moeglich ist, dann ist es eigentlich trivial zu loesen.
Falls die Verbindung permanent moeglich ist, kann man die Tabelle der einen Datenbank einfach in die andere Verknuepfen, wenn nicht kann man die Syncronisierung per Knopf starten, am einfachsten mittels Docmd.TransferDatabase.
Was auch noch ein Moeglichkeit waere, die Datenbank ueber das Internet (FTP) laden und dann syncronisiern, dazu gibt es fertige Komponenten im Nezt fuer lau.
Oder folgenden Code mit FTP=Basics fuer die WinINetAPI:
Option Compare Database
Option Explicit
Private Const INTERNET_OPEN_TYPE_PRECONFIG = 0
Private Const INTERNET_INVALID_PORT_NUMBER = 0
Private Const INTERNET_FLAG_RELOAD = &H80000000
Private Const INTERNET_SERVICE_FTP = 1
Private Const FTP_TRANSFER_TYPE_BINARY = &H2
Private Const FTP_TRANSFER_TYPE_ASCII = &H1
Public ErrMsg
Private Declare Function FtpCreateDirectory Lib „wininet.dll“ Alias „FtpCreateDirectoryA“ _
(ByVal hFtpSession As Long, ByVal lpszDirectory As String) As Long
Private Declare Function FtpSetCurrentDirectory Lib „wininet.dll“ Alias „FtpSetCurrentDirectoryA“ _
(ByVal hFtpSession As Long, ByVal lpszDirectory As String) As Long
Private Declare Function FtpGetCurrentDirectory Lib „wininet.dll“ Alias „FtpGetCurrentDirectoryA“ _
(ByVal hFtpSession As Long, ByVal lpszCurrentDirectory As String, lpdwCurrentDirectory As Long) As Long
Private Declare Function InternetWriteFile Lib „wininet.dll“ _
(ByVal hFile As Long, ByRef sBuffer As Byte, ByVal lNumBytesToWite As Long, _
dwNumberOfBytesWritten As Long) As Integer
Private Declare Function FtpOpenFile Lib „wininet.dll“ Alias „FtpOpenFileA“ _
(ByVal hFtpSession As Long, ByVal sBuff As String, ByVal Access As Long, ByVal Flags As Long, ByVal Context As Long) As Long
Private Declare Function FtpPutFile Lib „wininet.dll“ Alias „FtpPutFileA“ _
(ByVal hFtpSession As Long, ByVal lpszLocalFile As String, _
ByVal lpszRemoteFile As String, _
ByVal dwFlags As Long, ByVal dwContext As Long) As Long
Private Declare Function FtpDeleteFile Lib „wininet.dll“ _
Alias „FtpDeleteFileA“ (ByVal hFtpSession As Long, _
ByVal lpszFileName As String) As Long
Private Declare Function InternetCloseHandle Lib „wininet.dll“ _
(ByVal hInet As Long) As Long
Private Declare Function InternetOpen Lib „wininet.dll“ Alias „InternetOpenA“ _
(ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, _
ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
Private Declare Function InternetConnect Lib „wininet.dll“ Alias „InternetConnectA“ _
(ByVal hInternetSession As Long, ByVal sServerName As String, ByVal nServerPort As Integer, _
ByVal sUsername As String, ByVal sPassword As String, ByVal lService As Long, _
ByVal lFlags As Long, ByVal lContext As Long) As Long
Private Declare Function FtpGetFile Lib „wininet.dll“ Alias „FtpGetFileA“ _
(ByVal hFtpSession As Long, ByVal lpszRemoteFile As String, _
ByVal lpszNewFile As String, ByVal fFailIfExists As Long, ByVal dwFlagsAndAttributes As Long, _
ByVal dwFlags As Long, ByVal dwContext As Long) As Long
Private Declare Function InternetGetLastResponseInfo Lib „wininet.dll“ _
Alias „InternetGetLastResponseInfoA“ _
(ByRef lpdwError As Long, _
ByVal lpszErrorBuffer As String, _
ByRef lpdwErrorBufferLength As Long) As Long
Private Declare Function FormatMessage Lib „kernel32“ Alias „FormatMessageA“ _
(ByVal dwFlags As Long, ByVal lpSource As Long, ByVal dwMessageId As Long, _
ByVal dwLanguageId As Long, ByVal lpBuffer As String, ByVal nSize As Long, _
Arguments As Long) As Long
Private Declare Function GetModuleHandle Lib „kernel32“ Alias „GetModuleHandleA“ _
(ByVal lpLibFileName As String) As Long
Private Declare Function FileTimeToLocalFileTime Lib „kernel32“ _
(lpFileTime As Any, lpLocalFileTime As Any) As Long
Private Const rDayZeroBias As Double = 109205# ’ Abs(CDbl(#01-01-1601#))
Private Const rMillisecondPerDay As Double = 10000000# * 60# * 60# * 24# / 10000#
Private hOpen As Long, hConnection As Long, hFile As Long, dwType As Long, dwSeman As Long
Public Function Win32ToVbTime(ft As Currency) As Date
Dim ftl As Currency
’ Call API to convert from UTC time to local time
If FileTimeToLocalFileTime(ft, ftl) Then
’ Local time is nanoseconds since 01-01-1601
’ In Currency that comes out as milliseconds
’ Divide by milliseconds per day to get days since 1601
’ Subtract days from 1601 to 1899 to get VB Date equivalent
Win32ToVbTime = CDate((ftl / rMillisecondPerDay) - rDayZeroBias)
Else
MsgBox Err.LastDllError
End If
End Function
Private Sub ErrorOut(ByVal dwError As Long, ByRef szFunc As String)
ErrMsg = CStr(dwError) & ": " & szFunc
End Sub
Public Function Verbinden(ServerName, UserName, Password) As Boolean
Verbinden = False
hOpen = InternetOpen(„FTP Module“, 1, vbNullString, vbNullString, 0)
hConnection = InternetConnect(hOpen, ServerName, INTERNET_INVALID_PORT_NUMBER, _
UserName, Password, INTERNET_SERVICE_FTP, dwSeman, 0)
If hConnection = 0 Then
ErrorOut Err.LastDllError, „InternetConnect“
Else
'ErrorOut 21, „Connected!“
Verbinden = True
End If
End Function
Private Function Verzeichnis(Verzeichni As String) As Boolean
If FtpSetCurrentDirectory(hConnection, Verzeichni) 1 Then
Verzeichnis = False
ErrorOut Err.LastDllError, „FtpSetCurrentDirectory“
Else
Verzeichnis = True
End If
End Function
Public Function DateiDownl(RemoteFileName As String, LocalFileName As String) As Boolean
If FtpGetFile(hConnection, LocalFileName, RemoteFileName, 0, _
INTERNET_FLAG_RELOAD, FTP_TRANSFER_TYPE_BINARY, 0) 1 Then
DateiDownl = False
ErrorOut Err.LastDllError, „FtpGetFile“
Else
DateiDownl = True
End If
End Function
Public Function DateiUpl(RemoteFileName As String, LocalFileName As String) As Boolean
Dim Tmp
If FtpPutFile(hConnection, LocalFileName, RemoteFileName, dwType, 0) 1 Then
DateiUpl = False
ErrorOut Err.LastDllError, „FtpPutFile“
Else
DateiUpl = True
End If
End Function
Public Function Trennen() As Boolean
If hConnection Then InternetCloseHandle hConnection
hConnection = 0
'ErrorOut 21, „Disconnected.“
End Function
=======================================
Tschau
Peter
[Bei dieser Antwort wurde das Vollzitat nachträglich automatisiert entfernt]