423,818 Members | 2,250 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,818 IT Pros & Developers. It's quick & easy.

Creating new field in code

P: n/a
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

Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


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

dixie

"Dixie" <di***@dogmail.com> wrote in message
news:43********@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

Nov 13 '05 #2

P: n/a
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" <di***@dogmail.com> wrote in message
news:43********@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


Nov 13 '05 #3

P: n/a
Thats what it was David. Thankyou.

dixie

"David Lloyd" <Da***@NoSpamPlease.com> wrote in message
news:xh******************@bignews5.bellsouth.net.. .
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" <di***@dogmail.com> wrote in message
news:43********@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

Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.