Automated Importing from Excel

N

nam81

Hi all-- I need a way for users to import records into a database from a
series of Excel files that, more likely than not, won't have consistent file
names. I've found VBA code that will allow the user to pick out a file
through a dialog box, but I can't figure out how to actually allow the user
to start that process. In other words, the user needs to call

---
strLocation = GetFile()

If Len(strLocation) > 0 Then
DoCmd.TransferSpreadsheet acImport, _
acSpreadsheetTypeExcel9, "Evaluations", _
strLocation, False, "IT-Contracted!B13:D95"

DoCmd.TransferSpreadsheet acImport, _
acSpreadsheetTypeExcel9, "Evaluations", _
strLocation, False, "IT-Contracted!F13:G95"
End If
---

where the function GetFile is defined in a module (and appears to work
correctly.) How can I put the user in a position to call this code and
actually complete the TransferSpreadsheet operations? I*was* a programmer in
a former life, but it was a while ago and I havealmost zero experience in VBA
syntax.
 
J

John Nurick

Usual way is to use a commandbutton on a form, and put the code in the
button's Click event procedure.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top