Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Dynamically Set Query "Column Headings" Property

Posted on 2008-09-29
5
Medium Priority
?
406 Views
Last Modified: 2012-06-27
I want to set a query's Column Headings property in VBA. Should be something like the below, just not sure of the syntax.
Any help is appreciated!
Thx,
MV
CurrentDb.QueryDefs (["qry_MYQUERY"].Properties.columnheadings = "A, B, C, D")
OR
Dim QDef As DAO.QueryDef
Set QDef = CurrentDb.QueryDefs("qry_MYQUERY")
QDef.Properties.columnheadings = "A, B, C, D")

Open in new window

0
Comment
Question by:Michael Vasilevsky
  • 3
  • 2
5 Comments
 
LVL 85
ID: 22599842
There is no such property. The only way to do this is to alias your columns:

SELECT sCustFirstName AS [First Name], sCustLastName AS [Last Name] FROM tCustomers

this would show the query with "First Name" and "Last Name" columns.
0
 
LVL 10

Author Comment

by:Michael Vasilevsky
ID: 22600028
For a crosstab query there is. At least in design view. Is it not accessible through VBA? My problem is with a cross tab if there are no values in a crosstab column that column disappears and my formatting is messed up when I export to Excel...
0
 
LVL 10

Author Comment

by:Michael Vasilevsky
ID: 22600905
Ah figured it out. I need to use "PIVOT tbl_MyTable.MyField In ('" & "A" & "', '" & "B" & "', '" & "C" & "');

That forces three columns regardless of if A, B, or C don't have any data.
Thanks!

MV
0
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 total points
ID: 22603523
Yes, it "aliases" query column names ... which is what I suggested you do. In other words, I provided you at least part of the answer.
0
 
LVL 10

Author Comment

by:Michael Vasilevsky
ID: 22613061
Ok the points are yours ;-)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

927 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