Want to read a Query list of results into a defined variable "as Collection" for later use (ie create reports)

The following code works great (Functions Main and OpenThisFile ) to select files from a folder and read into defined variable "FileToProcess As Collection" (I guess then renamed fil) and use that list of files to run through
an import process defined in a function "StartMe". 
What I want to do is read the results of a query into a similar collection variable and then use in a function like "StartMe" to run a series of reports.  The functions to do that below (PrintCKListTables and ReadQueryOfSDGs) currently
don't work erring out "For Each s In .selectedQuery".  I would appreciate any help guiding me how to fix function
      ReadQueryOfSDGs() As Collection
Thank you very much in advance for your help!
Public Function Main()
Dim FilesToProcess As Collection, fil
Dim initialFilePath As String
initialFilePath = CreateObject("WScript.Shell").specialfolders("C:\temp")
Set FilesToProcess = OpenThisFile(initialFilePath)
For Each fil In FilesToProcess
StartMe fil
Next fil
End Function
Public Function OpenThisFile(initialFilePath As String) As Collection
'Requires reference to Microsoft Office 12.0 Object Library.
Dim fDialog As Office.FileDialog
Dim varFile As Variant
'Clear listbox contents.
'Me.FileList.RowSource = ""
'Set up the File Dialog.
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
'Allow user to make multiple selections in dialog box.
.AllowMultiSelect = True
.InitialFileName = initialFilePath
'Set the title of the dialog box.
.Title = "Please select one or more files"
'Clear out the current filters, and add our own.
.Filters.Clear
.Filters.Add "XML Files", "*.XML"
'Show the dialog box. If the .Show method returns True, the
'user picked at least one file. If the .Show method returns
'False, the user clicked Cancel.
If .Show = True Then
'Loop through each file selected and add it to the list box.
Dim s
Set OpenThisFile = New Collection
For Each s In .SelectedItems
OpenThisFile.Add s
Next s
Else
MsgBox "You clicked Cancel in the file dialog box."
NotContinue = True
End If
End With
End Function
Public Function PrintCkListTables()
    Dim FilesToProcess As Collection, fil
    Dim ListSDGs As String
    Set FilesToProcess = ReadQueryOfSDGs(ListSDGs)
    For Each fil In FilesToProcess
        fNameExportpdfReport (fil)
    Next fil
End FunctionPublic Function ReadQueryOfSDGs() As Collection       DoCmd.OpenQuery "y_qs_DataIn_All_SDGList"
       Dim s
       Set ReadQueryOfSDGs = New Collection
       For Each s In .selectedQuery
       ReadQueryOfSDGs.Add s
       Next s
End Function

There are a few problems here. In function PrintCkListTables() you define a string variable ListSDGs and then use that as an argument to the function ReadQueryOfSDGs(), but ReadQueryOfSDGs() as written does not accept any arguments.  It's also not clear
what ListSDGs represents...a list of files, names of queries? Also, the line
For Each s In .selectedQuery in
ReadQueryOfSDGs()
references something called .selectedQuery which is undefined. 
Is it that you want ReadQueryOfSDGs() to loop through the records returned by a query and add a field from each record to a collection?  If so, something like the following might better serve you:
Public Function ReadQueryOfSDGs() As Collection
    Dim C As New Collection
    Dim rst As DAO.Recordset
    Set rst = DBEngine(0)(0).OpenRecordset("y_qs_DataIn_All_SDGList", dbOpenForwardOnly, dbReadOnly)
    Do Until rst.EOF
        C.Add rst!MyField ' where MyField is the field in y_qs_DataIn_All_SDGList you want to add to your collection
        rst.MoveNext
    Loop
    rst.Close
    Set rst = Nothing
    Set ReadQueryOfSDGs = C
End Function

Similar Messages

  • Need to get select result into a shell variable.

    Hi,
    I want to get below command output into a OS variable. Which will be used later in the shell script. Can you please advice how to go about it?
    VAR v_tool_execution_id NUMBER;
    EXEC :v_tool_execution_id := trcanlzr.trca$p.get_tool_execution_id;
    SELECT TO_CHAR(:v_tool_execution_id) tool_execution_id FROM DUAL;
    I can't do following
    VAR1=`sqlplus -s $unpwd <<EOF
    VAR v_tool_execution_id NUMBER;
    EXEC :v_tool_execution_id := trcanlzr.trca$p.get_tool_execution_id;
    SELECT TO_CHAR(:v_tool_execution_id) tool_execution_id FROM DUAL;
    EOF`
    Since tool execution is specific to session and exiting will not server my purpose since i need to run another command which generates a file name using tool execution id.
    Thanks for your time.
    Regards,
    Nagendra Chillale

    Actually the idea is the same. Instead of getting the variable into a shell script, call the shell script which use the variable from sqlplus. I attempted to include the line to call a shell script but had a mistake :P
    The last line should be
    SQL> host /path/to/second/part.sh &exec_idAnother way is to spool the variable into a file, then read the file into a variable in your shell script. You need to use head / tail command to extract the desired row, because Oracle adds blank lines, headers, etc in its spool output
    In your SQL script
    SQL> spool tool_execution_id.txt
    SQL> SELECT TO_CHAR(:v_tool_execution_id) tool_execution_id into :vtemp FROM DUAL;
    SQL> spool offIn your shell script (the desired line appeared in the second last line in my case)
    tool_execution_id=`tail -2 tool_execution_id.txt|head -1`
    echo $tool_execution_idEdited by: thtsang on Mar 30, 2010 11:43 AM

  • SQL Query -How2bring multiple results into one field using Formatted Search

    Hi Everyone
    i am trying to bring in the results of the field dbo.Lot_ITEM.LOT using a formatted search into a row level using the following query:
    SELECT     dbo.LOT_ITEM.LOT
    FROM       dbo.DLN1 INNER JOIN dbo.LOT_ITEM ON dbo.DLN1.ItemCode = dbo.LOT_ITEM.ITEM
    WHERE     dbo.LOT_ITEM.ITEM=$[DLN1.ItemCode]
    however the result of the dbo.Lot_ITEM.LOT field could be more then one value depending on how many lots are assigned for that item
    (for example this query would be similar to assigning batch/serial numbers to an item being despatched - as you can choose multiple batches/serials depending on the quantities available and required and then move from the left to the right side of the selection window) if that makes sense!
    is it possible to bring in the multiple results into one field? and how can i amend the above query to include this?
    Thankyou in advance :o)
    Edited by: Asma Bi on Apr 23, 2008 7:22 PM
    Edited by: Asma Bi on Apr 23, 2008 7:24 PM

    Hi Suda
    Thanks for replying :o) but im not sure about the query?
    just to simplify it (as the query im working with is to do with 3rd party addons) i have used the serial/batchs field instead and used standard demo database fields from SBO 2005 sp01:
    SELECT     dbo.ixvSerialNoFact.SRI1_IntrSerial
    FROM       dbo.DLN1 INNER JOIN
                    dbo.ixvSerialNoFact ON dbo.DLN1.DocEntry = dbo.ixvSerialNoFact.SRI1_BaseEntry
    WHERE     dbo.ixvSerialNoFact.ItemCode='g1000' and dbo.ixvSerialNoFact.SRI1_BaseEntry = '193'
    The above brings me the relevant results but when i change it to be used in a formatted search:
    SELECT     dbo.ixvSerialNoFact.SRI1_IntrSerial
    FROM       dbo.DLN1 INNER JOIN
                    dbo.ixvSerialNoFact ON dbo.DLN1.DocEntry = dbo.ixvSerialNoFact.SRI1_BaseEntry
    WHERE     dbo.ixvSerialNoFact.ItemCode=$[dln1.itemcode] and dbo.ixvSerialNoFact.SRI1_BaseEntry = $[dln1.DocEntry]
    i cant seem to get it to work - now this may be because the serial number is not allocated until teh record is added to the system, however when this happens i am unable to go back in and manually trigger the query as the delivery note rows cannot be selected!
    i  think as what im originally wanting an answer for is same as this example, im wanting to know if this is even possible?
    Thanks
    Edited by: Asma Bi on Apr 24, 2008 3:53 PM
    Edited by: Asma Bi on Apr 24, 2008 3:55 PM

  • Want to read out put from Solaris System into Oracle Form

    Hi all
    I want some code of trigger which on fire get output from Solaris system into Windows i.e When I press push button window base system sent "df -kh" command to "\\172.16.3.16" and display output into text box.
    BR//

    When I press push button window base system sent "df -kh" command to " 172.16.3.16" and display output into text box.This can be accomplished by using a Host call to run the system command. You will need to output the results of the system command to a file and then read contents of the file into your form. The HOST built-in has a limitation, however. The HOST built-in can only execute commands on the Application Server (AS), so hopefully, the "Solaris" system you mentioned is your AS. Once the HOST call completes and the output file is created, you can read the contents of the file using the TEXT_IO built-in.
    Hope this helps,
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • Archiving to DVD, but want it for later use

    Hi,
    I have read a number of posts about archiving footage, but either I am daft or my specific concerns haven't quite been answered.
    I have a number of short clips (20-25 minutes) that have filled up my hard drive. They are all above DVD storage limitations, but I need to take them off. However, I am not totally done with them. I may want to re-edit some of them later.
    The other posts seem to suggest my only options are re-exporting them to tape or getting an external hard drive.
    Is there no other way?

    What other way are you looking for???
    Back up methods:
    1) Back up tape drives. Most reliable, extremely cost ineffective for individual use.
    2) Back up video to miniDV tape. Best option to archive video material. Cost effective but time consuming.
    3) Use hard drives. Depending on the frequency of needing hard drives, purchasing a hot swappable case can be beneficial. Hard drives are inexpensive per GB, the fastest of all options, and fairly reliable.
    4) Optical Media. The least reliable of the back up options. Time consuming sorting and burning media. Cost per GB is comparable to hard drives but seems less expensive as you can by a spindle of 20 discs for less than a hard drive.
    If there is another back up option, I don't know of it!
    Mike

  • Function/Procedure help - just want to build simple query and show results

    I'd like a simple "histogram" function - perhaps there is one built-in I'm not aware of. I just want to count discrete values of a column. So I'm constantly writing queries of the form:
    select column_name, count(*)
    from table_name
    group by column_name
    order by column_name;
    and I'm trying to write a function that will allow me to just type:
    execute whatever(column_name, table_name)
    or select whatever(column_name, table_name) from ?
    and get the equivalent results from the query above.
    How do you, or can you, write a procedure to take column/table names as inputs, substitue them into a query, execute the query and just display the results of that query? As I'm trying to figure out how to do this via google search, I keep going down rabbit holes of creating temporary tables/data types/records/refcursors etc. and I can't get any of it to compile. I'm not a DBA or SQL expert, so I'm hoping there's a simple way to accomplish this (without having to store and then process the "results" one row at a time)

    If I understand the requirement correctly, a simple pipelined function will do it:
    Dynamic
    GROUP_VALUE                    NUM_RECS
    10                                    1
    20                                    2
    30                                    6
    40                                    1
    50                                   45
    60                                    5
    70                                    1
    80                                   34
    90                                    3
    100                                   6
    110                                   2
                                          1
    12 rows selected.
      1  SELECT *
      2* FROM TABLE (Gen_Counts.Group_Count ('EMPLOYEES', 'DEPARTMENT_ID'))
    Static
    DEPARTMENT_ID   COUNT(*)
               10          1
               20          2
               30          6
               40          1
               50         45
               60          5
               70          1
               80         34
               90          3
              100          6
              110          2
                           1
    12 rows selected.
      1  SELECT department_id, Count(*)
      2    FROM employees
      3   GROUP BY department_id
      4*  ORDER BY 1The types and package code is:
    CREATE OR REPLACE TYPE group_count_type IS OBJECT
        (group_value VARCHAR2(4000), num_recs NUMBER);
    CREATE OR REPLACE TYPE group_count_list_type IS TABLE OF group_count_type;
    CREATE OR REPLACE PACKAGE Gen_Counts IS
    FUNCTION Group_Count (p_tab_name VARCHAR2, p_col_name VARCHAR2) RETURN group_count_list_type PIPELINED;
    END Gen_Counts;
    CREATE OR REPLACE PACKAGE BODY Gen_Counts IS
    FUNCTION Group_Count (p_tab_name VARCHAR2, p_col_name VARCHAR2) RETURN group_count_list_type PIPELINED IS
      l_cur             SYS_REFCURSOR;
      l_rec_list    group_count_list_type;
      l_cur_str     VARCHAR2(1000) := 'SELECT group_count_type (' || p_col_name || ', Count(*)) FROM ' || p_tab_name ||
        ' GROUP BY ' || p_col_name || ' ORDER BY ' || p_col_name;
    BEGIN
      OPEN l_cur FOR l_cur_str;
      DBMS_Output.Put_Line (l_cur_str);
      LOOP
        FETCH l_cur BULK COLLECT
         INTO l_rec_list LIMIT 1000;
        EXIT WHEN l_rec_list.COUNT = 0;
        FOR i IN 1..l_rec_list.COUNT LOOP
          PIPE ROW (group_count_type (l_rec_list(i).group_value, l_rec_list(i).num_recs));
        END LOOP;
      END LOOP;
    END Group_Count;
    END Gen_Counts;
    /Edited by: BrendanP on 06-Sep-2012 07:18
    Just to be clear - I'm not saying it's a great idea to do that, just that's a way of doing it technically. I'd just use the static way myself.

  • Can query output the result into excel with a fix format?

    Hi Expert,
    My user giving me a requirement for new reports. They do not want the standard SAP report format but they want the result to be populate into a excel template with their own fix format. Can BW generate the report like this? Or it is out of the functionality of BW. FYI, I'm using SAP BI 7.0.
    Thanks!
    Regards.

    Hi Ang,
    You have a way to do through the Bex Analyzer.
    Please get the excel template in that please use a analysis design item in the place of the query result display.
    Then after adding the analysis item then please assign a DP (data provider) with the query you have created.
    After that please save the work book in your roles or fav's.
    Note: some important settings has to be changed for the workbook.
    In workbook settings, tick mark the property "REFRESH upon open of work book"
    With Regards,
    Ravi

  • I am in the process of trying to send some "photos" from iPhoto to a self publishing company and they want it sent CMYK as opposed to RGB. The "photos" were printed beautifully for 2 books I created at an earlier date. I want to send in the right format

    How do you convert iPhotos to CMYK? I want to send "artwork" which are essentially photos to a self publishing company for a children's book and don't know how to do this. The iBooks I created are beautiful and vibrant. Why can't I just send the photos? They want all artwork tiff and CMYK with at least 300dots on resolution?

    Photoshop is a very  expensive application. GraphicConverter can convert RGB files to CMTK and can set the PPI to what you need:
    GraphicConverter is the only 3rd party image editor other than the full Photoshop to be able to convert to CMYK.  You can get it here: Mac photo editing, Mac photo software, Mac photo-editing - GraphicConverter
    OT

  • How to execute a function and return the result into a bind variable

    Hi,
    I am trying to calculate the sum of salaries of all persons with a particular JOB_ID using a function TOTAL_INCOME(v_job_id).
    create or replace function total_income
    +(v_job_id IN varchar2)+
    RETURN number IS
    v_total number(6);
    cursor get_sal is
    select salary from employees
    where job_id = v_job_id;
    BEGIN
    v_total := 0;
    for emp in get_sal
    loop
    v_total := v_total emp.salary;+
    end loop;
    dbms_output.put_line('Total salary of '||v_job_id||' is: '|| v_total);
    return v_total;
    END;
    Now I woud like to execute this function and assign the returned value into a bind variable test_sal
    variable test_sal number(6)
    SELECT total_income('AD_VP') into :test_sal FROM DUAL;
    dbms_output.put_line('Total Sal:'||:test_sal);
    This is returning the below errors:
    SELECT total_income('AD_VP') into :test_sal FROM DUAL
    *+
    Error at line 0
    ORA-01036: illegal variable name/number
    dbms_output.put_line('Total Sal:'||:test_sal);
    Error at line 3
    ORA-00900: invalid SQL statement
    Could someone help me what could be the problem?? Thanks for your time...

    Dear,
    If everything you will do will be done inside PL/SQL (stored procedure or stored function) then you don't have to care about bind variable.
    When using PL/SQL (static SQL) you will never encounter issues related to bind variables. PL/SQL itself takes care of your code and uses bind variables behind the scene.
    The only situation where you have to look carefully to the use of bind variables within PL/SQL is when you use Dynamic sql into stored procedures or functions.
    So, see in the light of the above comment, if you have to care about returning your function into a bind variable?
    Best regards
    Mohamed Houri

  • Cant save a character for later use in cs 4 (want to use in other projects)

    I am planning on making a character for a project and other projects but my "TEST DUMMY" couldn't be saved i made him a symbol and looked in the library, i loaded new project after restating flash and he wasn't in the library! (i did not save changes to the project someone told me saving it screws things up in cs 4)
    P.S: What is a good HD resolution?

    Ok i found out how so yes i do have to save changes to that place but to get in another projcet i kneed to go to File/Import/open external lybrary/file name/symbole name and then that works

  • How to list all tables/stored procedures used by the report

    All the reports i create are getting data from stored procedure(s). Is there a way to obtaining a listing of all the stored procedures without having to open report by report and check under Database > Set Datasource Location > Properties > Table Name?
    Finding this info it would be extremely valuable, as it would help me to judge the impact of any changes that i might be considering to one or more of the stored proc.
    So far i maintained a manual listing but it is not up-to-date and reliable. I would rather prefer to get an updated listing every time i want to change/drop a stored procedure.
    Thanks so much for your help.
    Rick

    Dell can you be a little bit more specific about the SDK solution. I could ask one of the developers to help me but i need to gather more details.
    I took a look .rpt inspector Pro but it does not do what i need. All i need is the the listing of all the database tables (in my case stored procs) used in my reports. No need to replace or change anything. I need to scan the directory where i have all the reports for the different applications and get report names and table/stored procs used. i can export the txt file to excel and that's all.

  • How do I set bookmarks to bookmark a book so that I can read it offline, my school e-text book says to bookmark it for use offline ?

    I am going to college online and my e-text book said to bookmark my book to be used offline and it could be read offline. this is all the information it gave me or that I could find. I have WIN 7 and use Mozilla as my browser, I have Vipre as my antivirus, internet security, etc.

    hello, a site won't be stored for offline reading just by bookmarking it...
    however you could try a third-party extension like scrapbook to archive certain pages for later use in case you'll be offline: https://addons.mozilla.org/firefox/addon/scrapbook/

  • Is it possible to submit a list item and at same time query/search the results if parameters are matched.

    Hello,
    Is it possible to submit a list item and at same time query/search the results if parameters are matched.
    Example - user logon to site enter search parameters and hit submit button. Once done parameters gets saved in list and shows search results on page. I have been asked to do this with
    SP designer and InfoPath doesn’t work due items limits.
    Please suggest.
    Thanks,
    Manish
    Manish

    Hi Manish,
    may i ask if you need,
    when user account click the login button, it will be authenticate the user and then it will show search result page?
    may i know how the keyword of words to be put? is it together with the user account box, password and keyword?
    or it will be like, after user authenticate, it will redirect to search page, so that user may use the search page to input the keyword?
    Regards,
    Aries
    Microsoft Online Community Support
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

  • I have a VI and an attched .txt data file. Now I want to read the data from the .txt file and display it as an array in the front panel. But the result is not right. Any help?

    I have a VI and an attched .txt data file. Now I want to read the data from the .txt file and display it as an array in the front panel. But the result is not right. Any help?
    Attachments:
    try2.txt ‏2 KB
    read_array.vi ‏21 KB

    The problem is in the delimiters in your text file. By default, Read From Spreadsheet File.vi expects a tab delimited file. You can specify a delimiter (like a space), but Read From Spreadsheet File.vi has a problem with repeated delimiters: if you specify a single space as a delimiter and Read From Spreadsheet File.vi finds two spaces back-to-back, it stops reading that line. Your file (as I got it from your earlier post) is delimited by 4 spaces.
    Here are some of your choices to fix your problem.
    1. Change the source file to a tab delimited file. Your VI will then run as is.
    2. Change the source file to be delimited by a single space (rather than 4), then wire a string constant containing one space to the delimiter input of Read From Spreadsheet File.vi.
    3. Wire a string constant containing 4 spaces to the delimiter input of Read From Spreadsheet File.vi. Then your text file will run as is.
    Depending on where your text file comes from (see more comments below), I'd vote for choice 1: a tab delimited text file. It's the most common text output of spreadsheet programs.
    Comments for choices 1 and 2: Where does the text file come from? Is it automatically generated or manually generated? Will it be generated multiple times or just once? If it's manually generated or generated just once, you can use any text editor to change 4 spaces to a tab or to a single space. Note: if you want to change it to a tab delimited file, you can't enter a tab directly into a box in the search & replace dialog of many programs like notepad, but you can do a cut and paste. Before you start your search and replace (just in the text window of the editor), press tab. A tab character will be entered. Press Shift-LeftArrow (not Backspace) to highlight the tab character. Press Ctrl-X to cut the tab character. Start your search and replace (Ctrl-H in notepad in Windows 2000). Click into the Find What box. Enter four spaces. Click into the Replace With box. Press Ctrl-V to paste the tab character. And another thing: older versions of notepad don't have search and replace. Use any editor or word processor that does.

  • How To Make Search Query Showing the Result As List of Buttons.

    Can some one give me an idea how to start to make a Search Query showing the results as list of buttons.. i have already have my buttons with names. i just dont know how to make a search query.
    this is my on screen keyboard i made..
    im making a system that the result were a list of buttons.. showing like this
    This was supposed to be the output of the query that i need to do..
    Please help me.. i just need a idea or tips how to make this one.

    Here is code I posted recently for another question
    Public Class Form1
    Const BUTTON_SIZE As Integer = 20
    Const SPACE As Integer = 5
    Sub New()
    ' This call is required by the Windows Form Designer.
    InitializeComponent()
    ' Add any initialization after the InitializeComponent() call.
    Dim buttons As New List(Of List(Of MyRadioButton))
    For row = 1 To 6
    Dim newRow As New List(Of MyRadioButton)
    buttons.Add(newRow)
    For col = 1 To 6
    Dim button As New MyRadioButton()
    button.row = row
    button.col = col
    button.Height = BUTTON_SIZE
    button.Width = BUTTON_SIZE
    button.Left = col * (BUTTON_SIZE + SPACE)
    button.Top = row * (BUTTON_SIZE + SPACE)
    button.Name = String.Format("radGr1{0}_{1}", row.ToString(), col.ToString())
    Me.Controls.Add(button)
    newRow.Add(button)
    AddHandler button.CheckedChanged, AddressOf Radio_Change
    Next col
    Next row
    End Sub
    Private Sub Radio_Change(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim button As MyRadioButton = CType(sender, MyRadioButton)
    Dim row As Integer = button.row
    Dim col As Integer = button.col
    End Sub
    End Class
    Public Class MyRadioButton
    Inherits RadioButton
    Public row As Integer
    Public col As Integer
    End Class
    jdweng

Maybe you are looking for

  • Still photos in PRE 12 and output to HD DVD for TV

    Hi, I was using Final Cut Express 4 HD on my old iMac but bought a new late 2013 iMac and learned that FCE will not run on Mavericks (and if you install it you will destroy your OS X plugin manager without any chance to repair it)! Ok FC Pro X is far

  • Can I terminate our contract one line at a time?

    I am so incredibly frustrated with Verizon right now!  We had 5 lines- 4 smart phones (one of which still had unlimited internet), and a regular flip phone.  We wanted to put our youngest son on our plan, and upgrade flip to smart,  but were trying t

  • NEED HELP IN SQL+ CODING USING POINTERS

    GOOD MORNING BOARD, I HAVE A CODING ISSUE DEALING WITH POINTERS AND BUILDING TABLES USING THEM CAN SOMEONE PLEASE HELP?? I CAN SEND THE CODE TO U VIA ATTACHMENT THANK YOU IN ADVANCE A...

  • Transport request : tp check buffer for already imported requests

    Hi, I want to put a transport request on my prod. There was no problem on the quality. But on the prod, i have the message : "tp check buffer for already imported requests" and nothing appends. Do you have any idea how i can unlock this transport req

  • Description Meta Tag

    Hi all, I'm looking to update the 'Description Meta Tag' of my website, in the HTML is it this section I need to update: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> If it is, is there a word/character limit I can input in Drea