ACCESS VBA table name as imported text file

mansied

Member
Local time
Today, 08:05
Joined
Oct 15, 2020
Messages
100
Hello, I have this code which imports a *.txt file into a table.how can I say change the table to the name of the text file not a fixed name?

Private Sub ImportData_Click()

ImportCompleted = Empty

Dim path As String
path = FilePathText.Value & ""
Dim tblName As String

tblName = "ZM"
If path = "" Then
MsgBox "You need to select a file to import!"
Else
Call Importing.import_ZM(path, tblName)
End If
ImportCompleted = "Import Completed!"

End Sub
 
Parse the Path variable with MID() and RevInstr() and remove the extension and pass that to your function. ?
Of course, the table will need to exist.
 
Hi. @Gasman probably meant to say InStrRev()...
 
how can I say change the table to the name of the text file not a fixed name?
This sounds like a seriously bad idea. Access is not a spreadsheet. It is a relational database. table and column names should NEVER include data. So you wouldn't have a table named Microsoft or a column named PatHartman.

What are you going to do with this collection of tables? Perhaps, you need ONE table with an additional column that includes the name of the input file the data came from.
 

Users who are viewing this thread

Back
Top Bottom