Solved

SQL Server field names VBA

Posted on 2014-02-09
4
607 Views
Last Modified: 2014-02-09
I have a SQL server 2008 database with a table called Invoices.

Using Access 2007 VBA code, how do I get all the field names from the table Invoices.
0
Comment
Question by:Idarac
4 Comments
 
LVL 2

Expert Comment

by:Computer Egghead
Comment Utility
Link your SQL Server table into your Access database, and create a module that you can run with the code shown here:  TableInfo() function
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
if you can already query the table (ADODB), you simply can run this query
SELECT * FROM Invoices WHERE 1 = 0

Open in new window

, and loop on the recordset's FIELDS collection.
0
 
LVL 29

Accepted Solution

by:
IrogSinta earned 500 total points
Comment Utility
Here's some code you could play with:
    Dim rs As Recordset
    Dim fld As Field
    
    Set rs = CurrentDb.OpenRecordset("Select * From TABLENAME Where FALSE")
    For Each fld In rs.Fields
        Debug.Print fld.Name
    Next
    rs.Close
    Set rs = Nothing

Open in new window

Ron
0
 
LVL 1

Author Closing Comment

by:Idarac
Comment Utility
Works great ode was pretty close. Just had to play with it a bit
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

728 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

10 Experts available now in Live!

Get 1:1 Help Now