Re: Replica
- From: "Anthony England" <aengland@xxxxxxxxxx>
- Date: Wed, 11 Jan 2006 16:50:40 +0000 (UTC)
"Anthony England" <aengland@xxxxxxxxxx> wrote in message
news:dq38nb$5ns$1@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> "Piotr" <hokah@xxxxx> wrote in message
> news:1136993442.846747.48560@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>> Yes I have ment mdb file.
>> I want this process automated so or i can code it in VBA or I can use a
>> macro if available.
>> No one will have server copy opened as it willl be proccessing nightly.
>
>
> OK I will write a code example - in the next hour or two.
Create a form in the database with a button named 'cmdExport' in the code
behind the form you could put something like this (obviously you change
"C:\DeleteMe.mdb" and "MyTable" to whatever you need)
NOTE: This automatically deletes and re-creates the database - don't do this
to the wrong one!
Private Sub cmdExport_Click()
On Error GoTo Err_Handler
Dim strPath As String
Dim strTable As String
strPath = "C:\DeleteMe.mdb"
strTable = "MyTable"
If CreateDb(strPath) Then
If ExportTable(strPath, strTable) Then
MsgBox "Data Exported", vbInformation
End If
End If
Exit_Handler:
Exit Sub
Err_Handler:
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler
End Sub
Private Function CreateDb(strPath As String) As Boolean
On Error GoTo Err_Handler
Dim wks As DAO.Workspace
Dim dbs As DAO.Database
If Dir(strPath) <> "" Then
Kill strPath
End If
Set wks = DBEngine.Workspaces(0)
Set dbs = wks.CreateDatabase(strPath, dbLangGeneral)
CreateDb = True
Exit_Handler:
If Not dbs Is Nothing Then
dbs.Close
Set dbs = Nothing
End If
If Not wks Is Nothing Then
Set wks = Nothing
End If
Exit Function
Err_Handler:
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler
End Function
Private Function ExportTable(strPath As String, _
strTable As String) As Boolean
On Error GoTo Err_Handler
DoCmd.TransferDatabase acExport, "Microsoft Access", _
strPath, , strTable, strTable
ExportTable = True
Exit_Handler:
Exit Function
Err_Handler:
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler
End Function
.
- Follow-Ups:
- Re: Replica
- From: David W. Fenton
- Re: Replica
- References:
- Replica
- From: Piotr
- Re: Replica
- From: Red
- Re: Replica
- From: Piotr
- Re: Replica
- From: Anthony England
- Re: Replica
- From: Piotr
- Re: Replica
- From: Anthony England
- Re: Replica
- From: Piotr
- Re: Replica
- From: Anthony England
- Re: Replica
- From: Piotr
- Re: Replica
- From: Anthony England
- Replica
- Prev by Date: Re: Access VBA project locked
- Next by Date: Re: run access.exe on server side
- Previous by thread: Re: Replica
- Next by thread: Re: Replica
- Index(es):