jatfill
Registered User.
- Local time
- Today, 06:33
- Joined
- Jun 4, 2001
- Messages
- 150
Hello all,
My VBA journey continues...
I wrote the code shown below for a form... what is intended to happen is that a user selects two dbf files from their computer and then once they do, the transfer database procedure runs and imports the files they have selected.
I keep getting an "Invalid argument" error when I try to run the second part, but the file select portion works perfectly... I think the 'transfer database' section needs to be tweaked, but I'm stumped...
Access appears to want the folder name and the file name split, but I'm not sure how to write that based on a user-selected file... thanks!
here's the file select portions (2 command buttons, text fields ):
And here's the import portion:
[This message has been edited by jatfill (edited 07-20-2001).]
My VBA journey continues...
I wrote the code shown below for a form... what is intended to happen is that a user selects two dbf files from their computer and then once they do, the transfer database procedure runs and imports the files they have selected.
I keep getting an "Invalid argument" error when I try to run the second part, but the file select portion works perfectly... I think the 'transfer database' section needs to be tweaked, but I'm stumped...
Access appears to want the folder name and the file name split, but I'm not sure how to write that based on a user-selected file... thanks!
here's the file select portions (2 command buttons, text fields ):
Code:
Private Sub cmdFileOpen_Click()
Dim strFilter As String
Dim strInputFileName As String
strFilter = ahtAddFilterItem(strFilter, "Import Files (*.DBF)", "*.DBF")
strInputFileName = ahtCommonFileOpenSave(Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select the data file...", _
Flags:=ahtOFN_HIDEREADONLY)
Me.txtFileNameData.Value = strInputFileName
End Sub
Private Sub cmdFileOpen2_Click()
Dim strFilterPlan As String
Dim strInputFileNamePlan As String
strFilterPlan = ahtAddFilterItem(strFilterPlan, "Import Files (*.DBF)", "*.DBF")
strInputFileNamePlan = ahtCommonFileOpenSave(Filter:=strFilterPlan, OpenFile:=True, _
DialogTitle:="Please select the plan file...", _
Flags:=ahtOFN_HIDEREADONLY)
Me.txtFileNamePlan.Value = strInputFileNamePlan
End Sub
And here's the import portion:
Code:
Private Sub process_esol_Click()
On Error GoTo process_esol_Err
If (MsgBox("Existing charges will be archived. Are you sure you want to continue?", 1, "New Magtape Import") = 1) Then
DoCmd.TransferDatabase acImport, "dBase IV", , acTable, txtFileNameData, "RAW_DATA", False
DoCmd.TransferDatabase acImport, "dBase IV", , acTable, txtFileNamePlan, "PLAN", False
If (MsgBox("Import was completed successfully. Would you like to create the data files now?", 1, "Import Finished") = 1) Then
DoCmd.TransferText acExportFixed, "ESOL_CALLDATA Export Specification", "ESOL_CALLDATA", "P:\esol_data.txt", False, ""
DoCmd.TransferText acExportFixed, "PLAN FEES EXPORT SPECS", "PLAN_FEES_EXPORT", "P:\esol_plan.txt", False, ""
Beep
MsgBox "Export completed successfully", vbOKOnly, "Finished"
End If
End If
DoCmd.CancelEvent
process_esol_Exit:
Exit Sub
process_esol_Err:
MsgBox Error$
Resume process_esol_Exit
End Sub
[This message has been edited by jatfill (edited 07-20-2001).]