Solved

Access Query / Macro

Posted on 2014-03-15
6
474 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 119

Expert Comment

by:Rey Obrero
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 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 39932214
it must be the Transfer Specification Name ECD
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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 34

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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server functions 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 Microsoft Ac…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

708 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