Solved

Access Query / Macro

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Password on a button in Access 2013 7 33
Explanation of Access VBA code 2 35
Run Time Error 3071 26 34
Restrict list data depending upon user name 3 19
Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

947 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

22 Experts available now in Live!

Get 1:1 Help Now