MarcelMegens
Registered User.
- Local time
- Today, 10:10
- Joined
- Jun 8, 2004
- Messages
- 16
I have created an VBA from a macro See below:
The name of the text-files varies from time to time, the rest of the process doesnt. Can someone point me in the right direction (or send an example) how I could replace the hardcoded filename"C:\Documents\CHK.csv" with the code that would open an explorer window, where I can simply select the file, and click on open or import, after which this file is import and the remaining queries can run?
(With the "explorer-window" I mean a window similar to what you get if you want to open a word or excel file, via File, Open....)
'------------------------------------------------------------
' MCR_ImportCHK_from_c_Documents
'
'------------------------------------------------------------
Function MCR_Import_from_c_Documents()
On Error GoTo MCR_Import_from_c_Documents_Err
DoCmd.SetWarnings False
DoCmd.CopyObject "", "CHK", acTable, "baseCHK"
DoCmd.TransferText acImportDelim, "CHK", "CHK", "C:\Documents\CHK.csv", False, ""
DoCmd.OpenQuery "Qry_Convert2", acViewNormal, acEdit
DoCmd.OpenQuery "Qry_Convert3", acViewNormal, acEdit
DoCmd.OpenQuery "Qry_ConvertDeleteXXXlink", acViewNormal, acEdit
MCR_Import_from_c_Documents_Exit:
Exit Function
MCR_Import_from_c_Documents_Err:
MsgBox Error$
Resume MCR_Import_from_c_Documents_Exit
End Function
The name of the text-files varies from time to time, the rest of the process doesnt. Can someone point me in the right direction (or send an example) how I could replace the hardcoded filename"C:\Documents\CHK.csv" with the code that would open an explorer window, where I can simply select the file, and click on open or import, after which this file is import and the remaining queries can run?
(With the "explorer-window" I mean a window similar to what you get if you want to open a word or excel file, via File, Open....)
'------------------------------------------------------------
' MCR_ImportCHK_from_c_Documents
'
'------------------------------------------------------------
Function MCR_Import_from_c_Documents()
On Error GoTo MCR_Import_from_c_Documents_Err
DoCmd.SetWarnings False
DoCmd.CopyObject "", "CHK", acTable, "baseCHK"
DoCmd.TransferText acImportDelim, "CHK", "CHK", "C:\Documents\CHK.csv", False, ""
DoCmd.OpenQuery "Qry_Convert2", acViewNormal, acEdit
DoCmd.OpenQuery "Qry_Convert3", acViewNormal, acEdit
DoCmd.OpenQuery "Qry_ConvertDeleteXXXlink", acViewNormal, acEdit
MCR_Import_from_c_Documents_Exit:
Exit Function
MCR_Import_from_c_Documents_Err:
MsgBox Error$
Resume MCR_Import_from_c_Documents_Exit
End Function