Importing text file

mugman17

Registered User.
Local time
Today, 23:03
Joined
Nov 17, 2000
Messages
110
Hi there:

I want to import a tabbed text file into Access. Problem is the text file is updated each day with a different name, and the user wants it automated. The fields would be the same each day.

Basically I want to create a command button that would get the user to specify which text file to import by selecting it in their files. Is this possible?

Thanks.
 
In VBA Tools>references, add the reference for file dialogs which is in "Microsoft Office XX.X Object Library"

Then try:

Private Sub Command0_Click()
Dim fd As FileDialog
Dim fileString As String
Set fd = Application.FileDialog(msoFileDialogFilePicker)
fd.Filters.Add "Text Files (*.txt)", "*.txt"
fd.AllowMultiSelect = False
fd.Show
fileString = fd.SelectedItems(1)
DoCmd.TransferText acLinkDelim, "MySpec", "MyTable", fileString
End Sub
 
Sorry to butt in but where abouts in Calgary do you reside? I used to live there in 1968/9 in a place call Fairview. I went to Farview High. We came back to the UK due to my dad's health problems. I have always said that I would love to go back to Canada some day. That was the best 12 months of my childhood.

Interestingly, I was once working in a bar and this Canadian chap came to be served and I recognised his accent. The conversation went something like this..

Me: I used to live in Canada
Him: Where abouts?

Me: Calgary, Alberta
Him: Where abouts in Calgary?

Me: Fairview
Him: Where abouts in Farview?

Me: Fairview Drive
Him: What number?

Me: 147
Him: My mother lives at 145

Uncanny::eek:
 

Users who are viewing this thread

Back
Top Bottom