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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TransferDatabase Action

Status
Not open for further replies.

Shairal

Technical User
Oct 13, 2005
25
US
I am wanting to create a macro that imports a dBASE table. As I understand it, the third argument (Database Name) requires the full path of the table, which changes continually for me. Is there a way to leave this argument blank and have it prompt for the path each time? Thanks for the help!
 
I have tried - here is the code I'm using but I am unable to either leave the databasename off, or blank to be prompted for the location - I would appreciate any suggestions.

Sub ImportNewTable()

DoCmd.TransferDatabase transfertype:=acImport, databasetype:="dBase 5.0", databasename:="", objecttype:=acTable, Source:="mytable", destination:="NewTable"

End Sub
 
A starting point:
Sub ImportNewTable()
Dim strDir As String
strDir = InputBox("Enter DBaseV directory name", "Import mytable to NewTable")
If strDir <> "" Then
DoCmd.TransferDatabase acImport, "dBase 5.0", strDir, acTable, "mytable", "NewTable"
End If
End Sub

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I had to change the “mytable” to the actual table name (which never changes, just the path) as I kept getting errors, but other than that, it worked great! Thank you so much for the help!
 
The API stuff would allow you to use the File/Open dialog to find the source database.

You could use a form and tie it to a table to retain the last directory used on the import to reduce entry. Some people use one table full of system settings, the form could isolate the one field and allow the directory to changed, but each time the form is opened, that used directory would be displayed. Or you could use a DLookup routine to pull from the system table a default value for the inputbox.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top