Hello All,
I have code that I use to import a group of text files into my database. What I am coming across is that I forget what the last file was that I imported since they are moved off to a different server after I have copied them. I would like to set a textbox or label on my main form to display the file name of the last file that I imported. I have been able to pass this value to both of them, but have run into problems. I don't really want to have a table just for this info. I want to just use the lable and set the caption property of it to the file name. The problem is that the label doesn't hold the value I pass it after I close the form. What can I do to fix this.
This is what I have so far:
Thanks,
PROXI
I have code that I use to import a group of text files into my database. What I am coming across is that I forget what the last file was that I imported since they are moved off to a different server after I have copied them. I would like to set a textbox or label on my main form to display the file name of the last file that I imported. I have been able to pass this value to both of them, but have run into problems. I don't really want to have a table just for this info. I want to just use the lable and set the caption property of it to the file name. The problem is that the label doesn't hold the value I pass it after I close the form. What can I do to fix this.
This is what I have so far:
Code:
Private Sub bImportFiles_Click()
On Error GoTo bImportFiles_Click_Err
Call ChangeFilename
Dim strImportFile As String, strTableName As String
Dim strFile As String
Dim objFS As Object, objFolder As Object
Dim objFiles As Object, objF1 As Object
Dim strFolderPath As String
Dim strnew As String
strFileExt = ".txt"
strTableName = "test"
strFolderPath = "C:\Documents and Settings\parkes23\My Documents\Billing Recon\"
strImportFile = Dir(strFolderPath & "\*" & strFileExt)
strFile = strFolderPath & strImportFile
strnew = "\\Ohlewnas0240\psrp\zoo0212\FACT\Accrual-Billing\Completed Daily Files\"
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFS.GetFolder(strFolderPath)
Set objFiles = objFolder.files
For Each objF1 In objFiles
If Right(objF1.Name, 3) = "txt" Then
strFile = objF1
DoCmd.TransferText acImportFixed, "TxtImportSpec", strTableName, strFile
Name strFile As strnew & objF1.Name
End If
Next
[COLOR=red][b]Me.Label46.Caption = strImportFile[/b][/color red]
Set objF1 = Nothing
Set objFiles = Nothing
Set objFolder = Nothing
Set objFS = Nothing
bImportFiles_Click_Exit:
Exit Sub
bImportFiles_Click_Err:
MsgBox Err.Number & " " & Err.Description
Resume bImportFiles_Click_Exit
End Sub
Thanks,
PROXI