Hello,
I'm new here and looking for an easy wildcard (hopefully the right term in English) in the database-name.
At the ? below It's not working with % or * or $ of "?" and I want to make one script for all years.
Part of the code:
------------------------------------------------------------------------------------
Dim pad As String
Dim reg As String
Dim db As Object
Dim dbName As String
pad = Client.WorkingDirectory
Set db = Client.OpenDatabase ("SRT" & ? & "_financial_table.IMD")
and so on------------------------------------------------------------------------------------
There are 3 posible databases, each in a different folder:
* \Finance\SRT\2011\ SRT2011_financial_table.imd
* \Finance\SRT\2012\ SRT2012_financial_table.imd
* \Finance\SRT\2013\ SRT2013_financial_table.imd
Byhteway, I use IDEA 8.
Sorry for my English, but it is hard to translate into English jargon.
hwes
Offline
Last seen: 10 years 3 weeks ago
Joined: 03/31/2014 - 15:02
Hello hwes and welcome to the site.
Unfortunately you can not use wildcards but you can use variables in their place. So you could do something like this:
Dim iYear as integer
for iYear = 2011 to 2013
set db = Client.OpenDatabase ("SRT" & iYear & "_financial_table.IMD")
next i
Brian,
Thanks for your answer. The part <for iYear = 2011 to 2013> only runs partly. If the database is from 2011 it runs, but not with the database from 2012 of 2013.
If I change it into <for iYear = 2011 to 2012> it works for 2011 and 2012 but that's not what I was looking for.
Harm
Hi Harm, here is some sample code for you that hopefully will help you out. It will perform an extract on three files with different years. I just used the Sample-Detailed Sales.IMD file that is in the samples folder and copied and renamed it. If this doesn't help you out maybe you can post your code or explain exactly what you are doing. Good luck.
Thanks. I used your code exactly and changed the name of the file (into “Sample-2011 Detailed Sales.IMD”) and I changed a column (into SALES_PLUS_TAX), but it didn't work, sorry.
Let's try another one. The year is also in a folder, so is there a way to get it from the path of the working directory (like the code strFilePath I saw on this site)?
For example: working directory: C:\finance\srt\2012\financial_tables\
Goal is to extract "2012" and use it later in the script.
Any chance you could send me the script, I am really interested why it is not working.
Would the location of the 2012 always be in the same position in the working directory?
Yes.
Thanks. It works for me!
I have another question. How can I code the next selection:
If sYear=2010 or 2011 or 2012 then look for the database "SRT & sYear " & "_financial_table_Sum.IMD").
If sYear=2013 then look for the database "SRT" & sYear & "_financial_table.IMD")
I tried some things like If and Else in a function but it didn't work.
Pages