A
Access Tinkerer
I am in the process of writing module using vba in ACCESS 2003 which imports
forecasted financial data from a particular excel file based on three inputs.
I am trying to include an "error check" that will end the process if the
three inputs do not match specific data in the excel file. I'm not sure how
to go about doing this. Do you have any ideas what the best way to do this
would be? Below is the code I have for the import part so far if that is
helpful.
Sub Test1()
Dim ImportDir As String
Dim Forecast As String
Dim Version As String
Dim Country As String
Dim Path As String
ImportDir = "I:\MED\VisionFund International\Reports - MED misc\MFI
Forecasts\"
Forecast = InputBox("Enter Forecast Period")
Version = InputBox("Enter Version")
Country = InputBox("Enter Country")
Path = ImportDir + "MFI Forecasts " + Forecast + "\Version " + Version + "\"
+ Country + " Forecast " + Forecast + ".xls"
Select Case Forecast
Case ""
Case Else
DoCmd.TransferSpreadsheet acImport, 8, "Source Data", Path, True, "Data"
DoCmd.RunMacro "Build Global", 1
End Select
End Sub
forecasted financial data from a particular excel file based on three inputs.
I am trying to include an "error check" that will end the process if the
three inputs do not match specific data in the excel file. I'm not sure how
to go about doing this. Do you have any ideas what the best way to do this
would be? Below is the code I have for the import part so far if that is
helpful.
Sub Test1()
Dim ImportDir As String
Dim Forecast As String
Dim Version As String
Dim Country As String
Dim Path As String
ImportDir = "I:\MED\VisionFund International\Reports - MED misc\MFI
Forecasts\"
Forecast = InputBox("Enter Forecast Period")
Version = InputBox("Enter Version")
Country = InputBox("Enter Country")
Path = ImportDir + "MFI Forecasts " + Forecast + "\Version " + Version + "\"
+ Country + " Forecast " + Forecast + ".xls"
Select Case Forecast
Case ""
Case Else
DoCmd.TransferSpreadsheet acImport, 8, "Source Data", Path, True, "Data"
DoCmd.RunMacro "Build Global", 1
End Select
End Sub