Microsoft Access Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft Access Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 11th, 2005, 06:32 AM
DanSimp DanSimp is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 11 DanSimp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 41 m 45 sec
Reputation Power: 0
can I check if a column already exisits?

How do I check if a table column name exists?

Is this something that can be performed in visual basic?

Thanks in advance for any help you can give.

Reply With Quote
  #2  
Old July 11th, 2005, 12:55 PM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 5
You can use the following function as an example of how to determine if a field name exists in a table.

Function FieldExists() As Boolean
Dim db As Database
Dim tbl As TableDef
Dim fld As Field
Dim strName as String
Set db = CurrentDb
Set tbl = db.TableDefs("NameofTable")
strName = "NameOfField"
For Each fld In tbl.Fields
If fld.Name = strName Then
FieldExists = True
Exit For
End If
Next
If FieldExists Then
MsgBox "Field Name Exists"
Else
MsgBox "Field Name Does Not Exist"
End If
db.Close
End Function

Not sure of where you wanted to call this procedure, so it can be modified to suit your needs.

lwells

Last edited by lwells : July 11th, 2005 at 01:01 PM.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft Access Development > can I check if a column already exisits?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT