Solved

Access Query / Macro

Posted on 2014-03-15
6
482 Views
Last Modified: 2014-03-17
I wanted to create a new version of an Access Query that selects MORE columns from a table in the current version.

I selected the existing query, did a save as & gave it a different name.

I added the new fields & saved the query.

Then I wrote a Macro to run the new query; then I ran the Macro.

See attached screen shots.

When the Macro is run, it produces the SAME result as the old Macro/query. The new columns are NOT there.

I need to know what I am doing wrong; of course, I can send more screen shots if needed.

Thanks
LSS-MACR-Mo-2.jpg
Extr-Cust-actv-new.jpg
0
Comment
Question by:Richard Korts
6 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39931896
with the query viewed in datasheet,  do right click in any of the column name, and select  Unhide field, see if there are columns with the check box unchecked.

another option is,
try creating a NEW query, select all the columns that you need and save.
0
 

Author Comment

by:Richard Korts
ID: 39931997
Thanks.

I discovered (accidentally) that if I run the query DIRECTLY (Not from the Macro), it produces the right results.

So it must be the macro.

I attache the two steps of the macro; the Transder Text step must have a problem. Do you see any issues?

PS - This is Access 2003.

Thanks
Macro-Step-1.jpg
Macro-Step-2.jpg
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 39932214
it must be the Transfer Specification Name ECD
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 12

Expert Comment

by:jkaios
ID: 39932446
When the Macro is run, it produces the SAME result as the old Macro/query. The new columns are NOT there.

You can't achieve what you're looking for with a static query.  You need something dynamic that can able to select ALL fields from the specified table.

Sub runMyQuery()
   dim rs as Recordset
   dim sFile as string, iFile as integer
   iFile = freefile()
   sFile = "mo\lss_extr_cust_new.csv"
   Open sFile For Output as iFile
   set rs = currentDB.OpenRecordset("SELECT * FROM myTable")
   do until rs.EOF
     write #iFile, rs(0) & "," & rs(1) & "," & rs(2) '....and so forth
      rs.MoveNext
   loop 
   rs.close
   close iFile
End Sub

Open in new window

0
 
LVL 35

Expert Comment

by:PatHartman
ID: 39933380
Opening the query isn't necessary.  All you need to do is to run the TransferText.  The problem is with the TransferText.  Make sure it is executing the new query rather than the old one.  The TransferText runs the specified query to create the export file.  It doesn't use the query you opened.
0
 

Author Comment

by:Richard Korts
ID: 39934751
I removed the Transfer Specification Name; left it blank.

It works perfectly.

The help implies that, so I tried it.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now