Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Access Query / Macro

Posted on 2014-03-15
6
Medium Priority
?
506 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 total points
ID: 39932214
it must be the Transfer Specification Name ECD
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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 39

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 VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

722 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