PC Review


Reply
Thread Tools Rate Thread

Creating conditional clause in a module

 
 
Access Tinkerer
Guest
Posts: n/a
 
      13th Apr 2010
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

 
Reply With Quote
 
 
 
 
Dorian
Guest
Posts: n/a
 
      13th Apr 2010
Its easiest to just import the data and then examine it after importing to
see if its correct, you can always delete the records if it is not correct.
You could always open an Excel object from VBA and read it in Excel but that
will be quite complex.
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".


"Access Tinkerer" wrote:

> 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
>

 
Reply With Quote
 
Access Tinkerer
Guest
Posts: n/a
 
      13th Apr 2010
Could I create a similar conditional clause which compares the three values
in ACCESS tables and then ends the process if they do not match?

"Dorian" wrote:

> Its easiest to just import the data and then examine it after importing to
> see if its correct, you can always delete the records if it is not correct.
> You could always open an Excel object from VBA and read it in Excel but that
> will be quite complex.
> -- Dorian
> "Give someone a fish and they eat for a day; teach someone to fish and they
> eat for a lifetime".
>
>
> "Access Tinkerer" wrote:
>
> > 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
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Solution: Parsing a search string and creating an SQL where clause John H. Microsoft C# .NET 3 7th Sep 2010 03:01 PM
conditional where clause Berryl Hesh Microsoft C# .NET 1 10th Oct 2008 10:48 AM
Creating a Report from Several Tables WITH A CLAUSE CondtllyFrmttd Microsoft Access Reports 0 9th Jan 2006 04:28 PM
Creating query from string - NOT clause =?Utf-8?B?TWFCZWxs?= Microsoft Access Queries 7 2nd Dec 2004 05:34 PM
Creating a snapshot for a report requiring a dynamic Where clause William Ortenberg Microsoft Access Reports 0 13th Oct 2004 02:53 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:59 AM.