Connecting Tech Pros Worldwide Help | Site Map

Creating new field in code

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 13th, 2005, 01:27 PM
Dixie
Guest
 
Posts: n/a
Default Creating new field in code

I am trying to write code to add a field called "Additional" to an existing
table called "Faculty". When I run it as an on click event, it stops at the
line, .append fldTemp with the error message Run-time error '3191': Cannot
define field more than once.

Can someone please point out the error to me.

dixie

Private Sub AddField_Click()
Dim dbs As DAO.Database
Dim tdfFaculty As DAO.TableDef
Dim fldTemp As Field

Set dbs = CurrentDb()
Set tdfFaculty = dbs.TableDefs("Faculty")
Set fldTemp = tdfFaculty.CreateField("Additional", dbText, 255)

With tdfFaculty.Fields
.Append fldTemp
End With

End Sub




  #2  
Old November 13th, 2005, 01:27 PM
Dixie
Guest
 
Posts: n/a
Default Re: Creating new field in code

Answering my own questions AGAIN. There was nothing wrong with the code.
The field was already in the table. :-(

dixie

"Dixie" <dixie@dogmail.com> wrote in message
news:431e2eab$1@duster.adelaide.on.net...[color=blue]
>I am trying to write code to add a field called "Additional" to an existing
>table called "Faculty". When I run it as an on click event, it stops at
>the line, .append fldTemp with the error message Run-time error '3191':
>Cannot define field more than once.
>
> Can someone please point out the error to me.
>
> dixie
>
> Private Sub AddField_Click()
> Dim dbs As DAO.Database
> Dim tdfFaculty As DAO.TableDef
> Dim fldTemp As Field
>
> Set dbs = CurrentDb()
> Set tdfFaculty = dbs.TableDefs("Faculty")
> Set fldTemp = tdfFaculty.CreateField("Additional", dbText, 255)
>
> With tdfFaculty.Fields
> .Append fldTemp
> End With
>
> End Sub
>
>
>[/color]


  #3  
Old November 13th, 2005, 01:27 PM
David Lloyd
Guest
 
Posts: n/a
Default Re: Creating new field in code

Did you check the Faculty table to see if the field already exists in the
table? A table can only have one field with a specific name.

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


"Dixie" <dixie@dogmail.com> wrote in message
news:431e2eab$1@duster.adelaide.on.net...
I am trying to write code to add a field called "Additional" to an existing
table called "Faculty". When I run it as an on click event, it stops at the
line, .append fldTemp with the error message Run-time error '3191': Cannot
define field more than once.

Can someone please point out the error to me.

dixie

Private Sub AddField_Click()
Dim dbs As DAO.Database
Dim tdfFaculty As DAO.TableDef
Dim fldTemp As Field

Set dbs = CurrentDb()
Set tdfFaculty = dbs.TableDefs("Faculty")
Set fldTemp = tdfFaculty.CreateField("Additional", dbText, 255)

With tdfFaculty.Fields
.Append fldTemp
End With

End Sub




  #4  
Old November 13th, 2005, 01:27 PM
Dixie
Guest
 
Posts: n/a
Default Re: Creating new field in code

Thats what it was David. Thankyou.

dixie

"David Lloyd" <David@NoSpamPlease.com> wrote in message
news:xhrTe.14934$VU6.3331@bignews5.bellsouth.net.. .[color=blue]
> Did you check the Faculty table to see if the field already exists in the
> table? A table can only have one field with a specific name.
>
> --
> David Lloyd
> MCSD .NET
> http://LemingtonConsulting.com
>
> This response is supplied "as is" without any representations or
> warranties.
>
>
> "Dixie" <dixie@dogmail.com> wrote in message
> news:431e2eab$1@duster.adelaide.on.net...
> I am trying to write code to add a field called "Additional" to an
> existing
> table called "Faculty". When I run it as an on click event, it stops at
> the
> line, .append fldTemp with the error message Run-time error '3191': Cannot
> define field more than once.
>
> Can someone please point out the error to me.
>
> dixie
>
> Private Sub AddField_Click()
> Dim dbs As DAO.Database
> Dim tdfFaculty As DAO.TableDef
> Dim fldTemp As Field
>
> Set dbs = CurrentDb()
> Set tdfFaculty = dbs.TableDefs("Faculty")
> Set fldTemp = tdfFaculty.CreateField("Additional", dbText, 255)
>
> With tdfFaculty.Fields
> .Append fldTemp
> End With
>
> End Sub
>
>
>
>[/color]


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.