473,407 Members | 2,306 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

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

Nov 13 '05 #1
3 5230
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: gonzalo briceno | last post by:
I have been using phplib for a while and I really like the framework except for form creation. Maybe it is me but I in my opinion there isn't a good way to create forms or should I say, everything...
2
by: Greg Lindstrom | last post by:
Hello- I have created a class, FixedLengthRecord.py, that allows me to manipulate fixed length records in the routines I write. I recently converted it to read record layouts from an SQL server...
4
by: Jeremy Weiss | last post by:
Thanks to much help from everyone in my previous thread, I've made it a pretty fair ways into my billing/invoicing db. I'm now needing a way to cycle through all the records in a table and create...
1
by: longtim | last post by:
I have been having endless difficulty creating reports/queries that set any relevent parameters from controls in forms. I am creating an application under access 2003 but will target access...
1
by: Dixie | last post by:
I wish to add some fields to an existing table in code. I am using the following code from rkc. CurrentDb.Execute ("ALTER TABLE MyTable ADD MyNewField Text 25") This works , but I need to also set...
2
by: Ian Davies | last post by:
I have created a database with about 17 tables. I have been creating foreign keys some of which have worked but when creating others I get the message below ************************* 1005...
0
by: EiEiO | last post by:
Hello all. I am hoping I could get some suggestions on moving forward. My Challenge: Importing data from one table to another where the field names almost never match. My Form has a list...
3
by: solargovind | last post by:
Hi, I am New to this forum. I need steps that i do in creating subform. In main form, i have one table fields like vendor,account,due amount,balance amount and Requisition_id which is...
1
by: MichaelZ | last post by:
After all is done, I want query(s) which will give me the ability to create a report which will allow me to compare 3 apts with the parameters equaling bedroom size, and rents which are equal or...
3
by: jport | last post by:
Hi Everyone, Am attempting to use MS Access 2000 and ArcGIS to build a comprehensive Land Referencing system, that is orientated to the new and inexperienced user, while also being versatile...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.