Solved

SQL Server field names VBA

Posted on 2014-02-09
4
622 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
[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
4 Comments
 
LVL 2

Expert Comment

by:Computer Egghead
ID: 39845937
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 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39845953
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
ID: 39845981
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
ID: 39846193
Works great ode was pretty close. Just had to play with it a bit
0

Featured Post

Comparison of Amazon Drive, Google Drive, OneDrive

What is Best for Backup: Amazon Drive, Google Drive or MS OneDrive? In this free whitepaper we look at their performance, pricing, and platform availability to help you decide which cloud drive is right for your situation. Download and read the results of our testing for free!

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
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 …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

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