473,387 Members | 1,486 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How do I get the column names of a recordset?

88
I have a pivot query that is generated on the fly, so the column (or field names) are sometimes different after its generated.

I need to put the query into a recordset, pull the column names so I can use them as headers on a report, and then also reference them.

Also, is there a way to reference a record in a recordset by the index?

I'm using DAO recordsets, but if ADO is better I will switch.

(I'm using Access 2000/VB 6?)

Thank you!
May 18 '07 #1
1 22667
Dököll
2,364 Expert 2GB
I need to put the query into a recordset, pull the column names so I can use them as headers on a report, and then also reference them.
Hiya, fperri!

Assuming you've searched here and nothing popped up, here's a simple fix:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Sub FieldNames()
  3.        Dim Rst As Recordset
  4.        Dim s As Field
  5.  
  6.     Set Rst = YourDatabase.OpenRecordset("YourTableName")
  7.  
  8.         For Each s In Rst.Fields
  9.         MsgBox (s.name)
  10.         Next
  11.     Rst.Close
  12. End Sub
  13.  
  14.  
MsgBox can be modified to have a Label or TextBox instead. Give this a whirl, see what you have-)

Dököll
May 19 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Stephen Matthews | last post by:
Help please i have a file which im importing, however it is a single column, the data looks like C8517673505 N7062175 C8517673516 N7062178 C8517673527
8
by: Donna Sabol | last post by:
First, I should start by saying I am creating a database to be used by some very impatient, non-computer literate people. It needs to be seameless in it's operation from their point of view. I...
10
by: Colleyville Alan | last post by:
I am trying to turn a short and fat (63 columns) table into one that is tall and skinny (7 columns). Basically, I am trying to create a "reverse crosstab" using a looping structure in VBA along...
3
by: ssb | last post by:
Hello, This may be very elementary, but, need help because I am new to access programming. (1) Say, I have a column EMPLOYEE_NAME. How do I fetch (maybe, cursor ?) the values one by one and...
14
by: Niels | last post by:
Hi, I have a Acces Db with one Table. The Table has 4 rows (row 1 & 3 are integer and 2 & 4 are text). Now i want to export the Table to an Excel workbook. the next code i used is working...
2
by: Hefestus | last post by:
Hey everyone, I have never really used access before and i now find myself knee deep in it trying to solve a problem. Hopefully someone has an idea. Anything would be great. Here's the problem:...
6
by: A.M | last post by:
Hi I use a code similar to this to retrieve data from Oracle database: import cx_Oracle
3
by: dale.zjc | last post by:
I've got some bizarre behavior going on with my ASP code below. For some strange reason (and I'm a newbie to ASP so it's probably obvious to others) I can't display all the rows of data from the...
1
by: Billy | last post by:
I do a SELECT * from table command in an ASP page to build a text file out on our server, but the export is not to allow a field name rows of records. The first thing I get is a row with all the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.