Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get column names

Tags:

sql

vba

ms-access

I need to get all of the column names of a table using VBA or Access SQL and iterate through them for validation, does anyone have a solution to this, I have searched Google to no avail.

like image 485
Matt Avatar asked Jul 27 '10 13:07

Matt


People also ask

How do I get column names in SQL?

In SQL Server, you can select COLUMN_NAME from INFORMATION_SCHEMA. COLUMNS .

How do I get column names from a Dataframe?

You can get column names in Pandas dataframe using df. columns statement. Usecase: This is useful when you want to show all columns in a dataframe in the output console (E.g. in the jupyter notebook console).

How do I get a list of columns in pandas?

You can get the column names from pandas DataFrame using df. columns. values , and pass this to python list() function to get it as list, once you have the data you can print it using print() statement.

How do I get column names in R?

To find the column names and row names in an R data frame based on a condition, we can use row. names and colnames function. The condition for which we want to find the row names and column names can be defined inside these functions as shown in the below Examples.


2 Answers

This will work

Set db = CurrentDb()
Set rs1 = db.OpenRecordset("Table1")
Dim fld As DAO.Field
For Each fld In rs1.Fields
    MsgBox (fld.Name)
Next
Set fld = Nothing
like image 184
Fergal Moran Avatar answered Sep 20 '22 10:09

Fergal Moran


Dim l As Integer

For l = 0 To CurrentDb.TableDefs("tbl_Name").Fields.Count - 1
  Debug.Print CurrentDb.TableDefs("tbl_Name").Fields(l).name
Next l
like image 40
Jose Avatar answered Sep 19 '22 10:09

Jose