BamaColtsFan
Registered User.
- Local time
- Today, 06:25
- Joined
- Nov 8, 2006
- Messages
- 91
Once again, I can't quite figure out how to get what I need...
I am working with a user defined function that accepts 3 values. I am using TransferText to load files into specific tables in my database. If I code each one individually, my code works great (thanks to the help I get from you fine folks). The problem is that I have about 24 files to load. What I want to do is have just one function that takes in the file name, import specification, and table name and loads the file. I would then call that function in a macro (tied to a command button) that would load the specified file (or files).
What I am getting is an error that says "The expression you entered has a function name that Microsoft Access can't find."
So, back to my usual position... What bone-head mistake did I make this time?
I am working with a user defined function that accepts 3 values. I am using TransferText to load files into specific tables in my database. If I code each one individually, my code works great (thanks to the help I get from you fine folks). The problem is that I have about 24 files to load. What I want to do is have just one function that takes in the file name, import specification, and table name and loads the file. I would then call that function in a macro (tied to a command button) that would load the specified file (or files).
What I am getting is an error that says "The expression you entered has a function name that Microsoft Access can't find."
So, back to my usual position... What bone-head mistake did I make this time?
Code:
Public Function AutoLoadFile(LoadFileName As String, LoadFileSpec As String, LoadFileTable As String)
Dim db As DAO.Database
Dim newPath As DAO.Recordset
Dim strPath As String
Set db = CurrentDb()
Set newPath = db.OpenRecordset("Set_Path")
strPath = newPath!path & LoadFileName
DoCmd.TransferText acImportDelim, LoadFileSpec, LoadFileTable, strPath
End Function