Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1369
  • Last Modified:

Is there a way to use a command button to execute a Saved Import?

I have two saved imports that I run once a month. Is there a way to enter these two saved  imports in a command button?
0
Conernesto
Asked:
Conernesto
  • 4
  • 4
  • 2
1 Solution
 
PatHartmanCommented:
Yes.  You would use one of the transfer methods.  TransferText, TransferSpreadsheet, ... depending on what type of file you are importing.  If it is a text file, you might have saved an import spec if you went to the Advanced tab.  In that case, you can include the name of the import spec in the TransferText method and that will use the same definition you saved.  Intellisense will help you with the arguments as you type.  We need more information to go further.
1. Type of File
2. Is there a file spec?  What is its name?
3. Do you have to search for the file or is it always the same name and location?
0
 
ConernestoAuthor Commented:
Let me know if the below does not answer the questions.

The path to one file is:
R:\GlobalSvcTax\Sales and Use Tax Compliance\Sales and Use Rates\ZipSales Data\FLATT.txt
The saved import name is:
Import-FLATT Rev

The path to the second file is:
R:\GlobalSvcTax\Sales and Use Tax Compliance\Sales and Use Rates\ZipSales Data\FLAT.txt
The saved import name is:
Import-FLAT Rev

The file is always in the same location
0
 
Rey Obrero (Capricorn1)Commented:
yes you can using the command line below

private sub btn_click()

docmd.RunSavedImportExport (nameOfSavedImportOrExport)


end sub
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
PatHartmanCommented:
    DoCmd.TransferText acImportFixed, "Import-FLATT Rev
", "table name", "R:\GlobalSvcTax\Sales and Use Tax Compliance\Sales and Use Rates\ZipSales Data\FLATT.txt", False

Open in new window

That may work but you'll need to replace "table name" with the actual table name.  I also made two assumptions that may need to change:
acImportFixed - the records are fixed format rather than delimited (acImportDelim)
False - there are no column headers.  Change this to True if the first row contains column headers.

As I said, intellisense is a wonderful tool and will guide you in typing code.
0
 
ConernestoAuthor Commented:
I am getting a compile error: Expected: end of statement. It appears to be going to the table name "MonthlyRateChanges". Below is what I entered for the command button.

Private Sub Command18_Click()

'This sub will import Import-FLATT Rev

    DoCmd.TransferText acImportFixed, "Import-FLATT Rev"", "MonthlyRateChanges", "R:\GlobalSvcTax\Sales and Use Tax Compliance\Sales and Use Rates\ZipSales Data\FLATT.txt", False
End Sub
0
 
ConernestoAuthor Commented:
How do I access the intellisense tool?
0
 
Rey Obrero (Capricorn1)Commented:
@Conernesto


did you see my post at http:#a39747021 ?






.
0
 
Rey Obrero (Capricorn1)Commented:
try this


private sub btn_click()

DoCmd.RunSavedImportExport ("Import-FLATT Rev")

DoCmd.RunSavedImportExport ("Import-FLAT Rev")



end sub



.
0
 
ConernestoAuthor Commented:
I was not able to see your post at http:#a39747021. Am I suppose to put this on the address bar?

The above code is great for importing my files!!

conernesto
0
 
Rey Obrero (Capricorn1)Commented:
@Conernesto,

<I was not able to see your post at http:#a39747021 >

to go to the post you just need to click on the hyperlink, http:#a39747021  is hyperlink.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now