Importing a file name into a feild

A

Antony Elson

Is there anyway to have it so that when I use the following code it then uses
the selected file name and inserts it into a filed on a file i.e.
"Hypertext". There is already some code that prompts for a file name, but it
always is the file that is being opened, so it seems pointless having to
select it again.

Function Budget_Import()
Dim strFilter As String
Dim strInputFileName As String
Dim Combo1 As String

'This code opens a select file window
strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.XLS)", "*.XLS")
strInputFileName =
ahtCommonFileOpenSave(InitialDir:="S:\Accounts\Share\Budget_2008-09\Access\",
_
Filter:=strFilter, OpenFile:=True, FilterIndex:=3, _
DialogTitle:="Please select Budget input file...", _
Flags:=ahtOFN_HIDEREADONLY)
'This Code transfers the selected file into the Bud_Import_TMP table
then to the Budget_Input_ManVar
If strInputFileName = "" Then MsgBox "Budget Import Aborted" Else
If strInputFileName <> "" Then DoCmd.DeleteObject acTable, "T_Hyperlink"
DoCmd.CopyObject "", "T_Hyperlink", acTable, "T_Hyperlink (Master)"
DoCmd.OpenTable "T_Hyperlink", acViewNormal, acEdit
DoCmd.RunCommand acCmdInsertHyperlink
DoCmd.Close , ""
DoCmd.TransferSpreadsheet acImport, 8, _
"Bud_Import_TMP", strInputFileName, True, ""
'If strInputFileName <> "" Then MsgBox "Budget Import Completed
Successfully"
End Function
 

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