Hey, I have a form with 9 text boxs:
Address Information
Portfolio
Strategy
Risk Management
Service Providers
Supporting Documents
Desicion
Monthly Data
Daily Data
Now I have a piece of code to display a promt box which lets me grab files from my computer. This is it:
Code:
Private Sub Command0_Click()
On Error GoTo Import_Err
Dim strFilter As String
Dim strInputFileName As String
strFilter = ahtAddFilterItem(strFilter, "CSV Files (*.CSV)", "*.CSV")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)
'Actual import
If Len(strInputFileName) > 0 Then
Me.AddInfo.value = strInputFileName
End If
Import_Exit:
Exit Sub
Import_Err:
MsgBox Error$
Resume Import_Exit
End Sub
How could I write this to run a string through the 9 text box names, and fill the correct text box based on the Button i click to prompt this. I want to make it a function so i can just call it from each command click rather then have the same code written over and over again.
Heres my form template:
Address Info ................txtBox........... CmdButton(0)
Portfolio Sec ...............txtBox........... CmdButton(1)
Strategy Sec ................txtBox........... CmdButton(2)
Risk Management.........txtBox........... CmdButton(3)
Service Providers .........txtBox........... CmdButton(4)
Supporting Documents.txtBox........... CmdButton(10)
Desicion ......................txtBox........... CmdButton(11)
Monthly Data................txtBox........... CmdButton(5)
Daily Data.....................txtBox........... CmdButton(12)
Each text box fills in the file path at which i select from the promt menu.
At the bottom of my form I have a button called import. when i click that button i want it to import all the files selected in the txt boxes.
Code:
If Len(strInputFileName) > 0 Then
DoCmd.TransferText acImportDelim, "Import Specification", "tbl_Import", strInputFileName, False, ""
End If
this doesnt work for me, I thought it could. How would I write this code to import everything (append) into the corresponding table. Reminder the txt boxes titles correspond with the tables. The CSV are in exact same format as tables IE Field names.
Thanks In advance, really appreciate the help here.