Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Transferdatabase

Status
Not open for further replies.

samotek

Technical User
May 9, 2005
197
0
0
BG
In copying tables i use the command Transferdatabase shown below.It is a good command, but i need the following refinement.
I want to copy the table only when the Yes/No field "accepted" in the table Unis is set to Yes.Can i do it in the command, and if not,
how can i set the condition ?


DoCmd.TransferDatabase TransferType, "Microsoft Access", appath, acTable, "Unis", "Unis"



 
I think you must DlookUp the Unis table.
 
Option Compare Database
Option Explicit

Function XferDb() As Boolean
' Comments :
' Parameters:
' Returns : String -
' Created : 12/18/05 09:21 e
' Modified :
'
' --------------------------------------------------
'Assumptions:
' There is a boolean field 'accepted' in the current database (if it's in another database
' change the 'Set dbs' statement).
'
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim appath As String
Dim TransferType As Long
On Error GoTo PROC_ERR
XferDb = False
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Unis", dbOpenSnapshot)
If (rst.EOF And rst.BOF) Then GoTo PROC_EXIT 'Make sure there's some records
appath = "C:\Databases\TheOtherDatabase.mdb"
TransferType = acExport
If (rst!accepted) Then
DoCmd.TransferDatabase TransferType, "Microsoft Access", appath, acTable, "Unis", "Unis"
XferDb = True
End If
PROC_EXIT:
rst.Close
Set rst = Nothing
dbs.Close
Set dbs = Nothing
Exit Function
PROC_ERR:
MsgBox "XferDb " & " - Err: " & Err.Description
Resume PROC_EXIT
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top