473,379 Members | 1,255 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

How to loop & substitute ???

Hi All,

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT MSysObjects.Name 
  3. FROM MSysObjects 
  4. WHERE (((MSysObjects.Type)=5)); 
  5.  
From above sql i will get list of queries in my MDB file

Assume Output of above query is
abc
xyz
lmn

I have to SUBSTITUE the above values 1 by one in below AND LOOP THEM TILL LAST??

Expand|Select|Wrap|Line Numbers
  1.  
  2. DoCmd.OutputTo acOutputQuery, "??",acFormatXLS, "D:\??" 
  3.  
  4. Example 
  5.  
  6. DoCmd.OutputTo acOutputQuery, "abc",acFormatXLS, "D:\abc" 
  7. DoCmd.OutputTo acOutputQuery, "xyz",acFormatXLS, "D:\xyz" 
  8.  
  9.  
May 18 '09 #1
2 1652
Megalog
378 Expert 256MB
This should work nicely for you:

Expand|Select|Wrap|Line Numbers
  1. Private Sub qryLoopToXLS()
  2.  
  3.     Dim rs As DAO.Recordset
  4.     Dim strSQL As String
  5.  
  6.     strSQL = "SELECT Name FROM MSysObjects WHERE Type=5"
  7.  
  8.     Set rs = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
  9.  
  10.     Do While Not rs.EOF
  11.         rs.MoveFirst
  12.         Do While Not rs.EOF
  13.             DoCmd.OutputTo acOutputQuery, rs!Name, acFormatXLS, "D:\" & rs!Name & ".xls"
  14.             rs.MoveNext
  15.         Loop
  16.     Loop
  17.     Set rs = Nothing
  18. End Sub
You may want to doublecheck that none of your queries are using any illegal filename characters, and do a replace for those character types.
May 18 '09 #2
Hi Megalog,

Thanks a lot it works.. finally my work finished with this...

Thanks thanks....
May 19 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

354
by: Montrose... | last post by:
After working in c# for a year, the only conclusion I can come to is that I wish I knew c. All I need is Linux, the gnu c compiler and I can do anything. Web services are just open sockets...
4
by: .Net Sports | last post by:
I am trying to display records from a recordset after sql statement: <% sqlstr ="SELECT horsename FROM tblhorseentry WHERE trackname = '" & request.querystring("trackname") & "' and racedate =...
9
by: adam | last post by:
hello Does exist in SQL language "for" loop ? If yes, what syntax does it has ? best wishes Adam
4
by: barney | last post by:
Hello, I' m using .NET System.Xml.XmlDOcument. When I do the following: XmlDocument xml = new XmlDocument(); xml.Load("blah"); .... xml.Save("blub"); I've got the problem that the following...
34
by: Frederick Gotham | last post by:
Is the domestic usage of the C "for" loop inefficient when it comes to simple incrementation? Here's a very simple program that prints out the bit-numbers in a byte. #include <stdio.h> #include...
14
by: dawnerd | last post by:
Hi, I am developing a CMS and came across something which has never happened to me before, and I re-wrote the specific script twice, both differently, and still had the same error. I'm not sure...
18
by: Andrew Wan | last post by:
I have been developing web applications with ASP & Javascript for a long time. I have been using Visual Studio 2003.NET. While VS2003 is okay for intellisense of ASP & Javascript, it's still not...
24
by: oliv29 | last post by:
Hello, Can anyone tell me how do i fill a structure's fields in a for loop ? #define MAX_FIELD_LEN 10 typedef struct { char field1; /*will store first string read from keyboard*/
3
by: james.kirin40 | last post by:
Hi everyone, I am using Python's re module to extract some data from html. The following code never returns, and I was wondering if someone can explain to me why. Is this a problem with my...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.