If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > get the names of fields from a view

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-16-03, 09:37
kfenstad kfenstad is offline
Registered User
 
Join Date: May 2003
Posts: 25
Arrow get the names of fields from a view

is this possible? i can do it from a table...

oServer.Databases.Item(sDatabase).Tables.Item(sTab le).Columns.Item(iLoop).Name

but i also need the names of columns from a view, so...

oServer.Databases.Item(sDatabase).Views.Item(sView ). ???

any help would be much appreciated, thank you!!!
Reply With Quote
  #2 (permalink)  
Old 05-16-03, 14:28
kfenstad kfenstad is offline
Registered User
 
Join Date: May 2003
Posts: 25
Cool Re: get the names of fields from a view

Quote:
Originally posted by kfenstad
is this possible? i can do it from a table...

oServer.Databases.Item(sDatabase).Tables.Item(sTab le).Columns.Item(iLoop).Name

but i also need the names of columns from a view, so...

oServer.Databases.Item(sDatabase).Views.Item(sView ). ???

any help would be much appreciated, thank you!!!
so... i figured out my own problem but i thought i would post it here in case anyone else would like to get view column info... which would be quite a coincidence! anyway...

i just linked to the system tables in sql server where my view is, and then created a recordset.

Set rsViewColumns = CurrentDb.OpenRecordset("SELECT dbo_syscolumns.name FROM dbo_sysobjects INNER JOIN dbo_syscolumns " _
& "ON dbo_sysobjects.id = dbo_syscolumns.id WHERE dbo_sysobjects.name = '" & sView & "'")

if "sView" is a string containing the name of the view, you get a recordset of all the column names. you also can get other info such as if the column is nullable or join the systypes table as well and get info about the column datatype. pretty easy!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On