473,756 Members | 2,977 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

copying and changing fields to another table can you change description at this time?

I was copying fields from one table to another.
IF the var name starts with milk I change it to egg and create it in
the destination table.
It works fine but I want to copy the description as well.

Short version :)

For Each fld In tdf.Fields
pos = InStr(fld.Name, "milk")
If pos > 0 Then
strName = Left(fld.Name, pos - 1) & "egg" &
Right(fld.Name, Len(fld.Name) - pos - Len("milk") + 1)
Set fldNew = tdf.CreateField (strName, dbInteger)
tdff.Fields.App end fldNew

if I do something like
Set fldNew = tdf.CreateField (strName, dbInteger)
fldNew.Descript ion = >>>the desctiption of the existing field
tdff.Fields.App end fldNew

this does not work.
IS there a way to edit the description when you create the new field?
or will I have to loop thru the code again to copy the description?

thanks big time for any pointers

jerry

Nov 13 '05 #1
3 2571
sparks <sp****@here.co m> wrote in message news:<bp******* *************** **********@4ax. com>...
@ I was copying fields from one table to another.
@ IF the var name starts with milk I change it to egg and create it in
@ the destination table.
@ It works fine but I want to copy the description as well.
@
@ Short version :)
@
@ For Each fld In tdf.Fields
@ pos = InStr(fld.Name, "milk")
@ If pos > 0 Then
@ strName = Left(fld.Name, pos - 1) & "egg" &
@ Right(fld.Name, Len(fld.Name) - pos - Len("milk") + 1)
@ Set fldNew = tdf.CreateField (strName, dbInteger)
@ tdff.Fields.App end fldNew
@
@ if I do something like
@ Set fldNew = tdf.CreateField (strName, dbInteger)
@ fldNew.Descript ion = >>>the desctiption of the existing field
@ tdff.Fields.App end fldNew
@
@ this does not work.
@ IS there a way to edit the description when you create the new field?
@ or will I have to loop thru the code again to copy the description?
@
@ thanks big time for any pointers
@
@ jerry

Steve Jorgensen wrote (1999/11/01) answering G. Manuel:
You can only add properties to an object after it is saved, not before. In
this case, you will have to save the tabledef before you can add custom
properties to its controls. G. Manuel wrote:
Dim db As Database
Dim tdf As TableDef
Dim fld As Field
Dim prop As Property

Set db = CurrentDb

' Create a new table
Set tdf = db.CreateTableD ef("zzjunk")

' Create one field in the table
Set fld = tdf.CreateField ("Field1", dbText, 30)

' Try to set Field Description property - does not exist!
' fld.Properties( "Descriptio n") = "My Description" ' Error: 3270
Property not found

' Create a new property for the field
Set prop = fld.CreatePrope rty("MyProp", dbText, "MyProp value")

' The following generates Error 3219. Invalid Operation.
' HELP says either the Property is read-only,
' or the Field does not allow user-defined Properties
fld.Properties. Append prop

fld.Properties. Refresh

' Add the field to the table
tdf.Fields.Appe nd fld

' Add the table to the database
db.TableDefs.Ap pend tdf

db.Close

End Function


P.S., Allen Browne wrote (1997/12/08):
:The trick with the Description property is that if any field does not
:have a Description entered, then the property does not exist, i.e.
:trying to reference it generates an error.

:The basic approach is:
:------------------------------------------------------------------------
:Function ShowDescrip (strTable)
: On Error GoTo Err_ShowDescrip
: Dim db As Database, tdf As TableDef, fld As Field, i As Integer
: Set db = CurrentDB()
: Set tdf = db.tabledefs(st rTable)
: Debug.Print "TABLE " & strTable & ": " &
:tdf.Properties ("Descriptio n")
: For i = 0 To tdf.fields.coun t - 1
: Set fld = tdf.fields(i)
: Debug.Print fld.Name, fld.Properties( "Descriptio n")
: Next
:
:Exit_ShowDescr ip:
: Exit Function
:Err_ShowDescri p:
: If Err = 3270 Then
: Resume Next
: Else
: MsgBox (Err & ": " & Error$), , "ShowDescri p()"
: End If
:End Function

It looks like looping again is your best option.

James A. Fortune
Nov 13 '05 #2
Thanks for your help. I could not find any way to do it and was not
sure if it was my limited exp or it was not a think that could be done
on creation.

btw is there a book that deals with this sort of thing.
Every book I have seen on access either deals with basic forms and
tables or is a reference that only deals with common coding things.

My book is access databases in a nutshell....I find it very good but
some things like this it does not deal with well..

thanks again
jerry

On 23 Jun 2004 14:56:59 -0700, ja******@oaklan d.edu (James Fortune)
wrote:
sparks <sp****@here.co m> wrote in message news:<bp******* *************** **********@4ax. com>...
@ I was copying fields from one table to another.
@ IF the var name starts with milk I change it to egg and create it in
@ the destination table.
@ It works fine but I want to copy the description as well.
@
@ Short version :)
@
@ For Each fld In tdf.Fields
@ pos = InStr(fld.Name, "milk")
@ If pos > 0 Then
@ strName = Left(fld.Name, pos - 1) & "egg" &
@ Right(fld.Name, Len(fld.Name) - pos - Len("milk") + 1)
@ Set fldNew = tdf.CreateField (strName, dbInteger)
@ tdff.Fields.App end fldNew
@
@ if I do something like
@ Set fldNew = tdf.CreateField (strName, dbInteger)
@ fldNew.Descript ion = >>>the desctiption of the existing field
@ tdff.Fields.App end fldNew
@
@ this does not work.
@ IS there a way to edit the description when you create the new field?
@ or will I have to loop thru the code again to copy the description?
@
@ thanks big time for any pointers
@
@ jerry

Steve Jorgensen wrote (1999/11/01) answering G. Manuel:
You can only add properties to an object after it is saved, not before. In
this case, you will have to save the tabledef before you can add custom
properties to its controls.

G. Manuel wrote:
Dim db As Database
Dim tdf As TableDef
Dim fld As Field
Dim prop As Property

Set db = CurrentDb

' Create a new table
Set tdf = db.CreateTableD ef("zzjunk")

' Create one field in the table
Set fld = tdf.CreateField ("Field1", dbText, 30)

' Try to set Field Description property - does not exist!
' fld.Properties( "Descriptio n") = "My Description" ' Error: 3270
Property not found

' Create a new property for the field
Set prop = fld.CreatePrope rty("MyProp", dbText, "MyProp value")

' The following generates Error 3219. Invalid Operation.
' HELP says either the Property is read-only,
' or the Field does not allow user-defined Properties
fld.Properties. Append prop

fld.Properties. Refresh

' Add the field to the table
tdf.Fields.Appe nd fld

' Add the table to the database
db.TableDefs.Ap pend tdf

db.Close

End Function


P.S., Allen Browne wrote (1997/12/08):
:The trick with the Description property is that if any field does not
:have a Description entered, then the property does not exist, i.e.
:trying to reference it generates an error.

:The basic approach is:
:------------------------------------------------------------------------
:Function ShowDescrip (strTable)
: On Error GoTo Err_ShowDescrip
: Dim db As Database, tdf As TableDef, fld As Field, i As Integer
: Set db = CurrentDB()
: Set tdf = db.tabledefs(st rTable)
: Debug.Print "TABLE " & strTable & ": " &
:tdf.Propertie s("Description" )
: For i = 0 To tdf.fields.coun t - 1
: Set fld = tdf.fields(i)
: Debug.Print fld.Name, fld.Properties( "Descriptio n")
: Next
:
:Exit_ShowDesc rip:
: Exit Function
:Err_ShowDescr ip:
: If Err = 3270 Then
: Resume Next
: Else
: MsgBox (Err & ": " & Error$), , "ShowDescri p()"
: End If
:End Function

It looks like looping again is your best option.

James A. Fortune


Nov 13 '05 #3
sparks <sp****@here.co m> wrote in message news:<41******* *************** **********@4ax. com>...
Thanks for your help. I could not find any way to do it and was not
sure if it was my limited exp or it was not a think that could be done
on creation.

btw is there a book that deals with this sort of thing.
Every book I have seen on access either deals with basic forms and
tables or is a reference that only deals with common coding things.

My book is access databases in a nutshell....I find it very good but
some things like this it does not deal with well..

thanks again
jerry


Any author that has written such a book is probably monitoring this
NG. You ought to be able to get some sample code from someone here or
get pointed to a good book. This NG IS the best place to be. A lot
of the information you find here is not in any book yet.

James A. Fortune
Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
18696
by: Gordon Burditt | last post by:
What's the easiest way to copy a row from one table to another (with the same schema), without knowing in advance the number and types of the columns? The problem: I have several sets of tables with a primary key of 'account', which contains an email address. If someone changes their email address, I need to change the 'account' field. Unfortunately, someone thought it would speed up lookups if instead of having one table 'settings',...
1
2073
by: Jonathan | last post by:
I've seen this subject here in a similar fashion, but not in a fashion that can easily be accomplished for my purpose. Simply put, I have a form, I have about 2 dozen fields on this form, that I may need to move to the next record. For example: first_name last_name address address_2
4
1818
by: Omey Samaroo | last post by:
I am using Employee_Number as a primary field in one table and in another table I have a field with the same name that it references in a one to many relationship. How do I change the primary field and update all the secondary fields at the same time ? Would referential integrity have anything to do with this ? Any help is appreciated, Thanks Omey
16
2464
by: StenKoll | last post by:
Help needed in order to create a register of stocks in a company. In accordance with local laws I need to give each individual share a number. I have accomplished this by establishing three tables (se below) then I run a query giving me a running total, which give me the first stock in the batch purchased by an individual, then I use this number and add the number of shares in order to find the number of the individuals' last share. So...
3
3025
by: Michael | last post by:
Hi everyone, I am trying to change the field names for a table that is being exported via Excel. Its a spreadsheet that our National Office sends us but even after promise after promise they keep changing the field names which makes it nearly impossible to run any pre-generated queries etc. The solution really is to get someone to check the field names before importing the spreadsheet but I want to do it in code. I have written
3
3422
by: radioman | last post by:
Hi all, I would appreciate some help please. I just need pointing in the right direction as I am at a loss. Basically I have a form (frmAddMaster) which displays two subforms "Master Stock subform" and "Client Stock Template subform". Each subform contains the following fields "Product ID,Product Description and Size". What I am trying to do is to select rows from the "Master Stock subform" and copy them to "Client Stock Template...
8
3724
by: Maxi | last post by:
There is a lotto system which picks 21 numbers every day out of 80 numbers. I have a table (name:Lotto) with 22 fields (name:Date,P1,P2....P21) Here is the structure and sample data: "Date","P1","P2","P3","P4","P5","P6","P7","P8","P9","P10","P11","P12","P13","P14","P15","P16","P17","P18","P19","P20","P21" 1/1/2005,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21 1/2/2005,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22
6
1402
by: Jeff Brooks | last post by:
I need to copy a record one access record into the same table. I just need to modify a couple fields that the user will change. Im sure there is an easy way to do it. I have started just reading the data and writing a SQL insert command, but there are a ton of fields. It would take forever to get the datatypes correct and the SQL formatted properly. Anyone know how to just copy a record and make a couple changes to it? Thanks Jeff
3
2739
MattFitzgerald
by: MattFitzgerald | last post by:
My Forms & Tables:- Main form is Frm_LE_List (contains Customer Details) Stored in Tbl_LE_List Which contains subform Frm_VOL_References (Contains Orders known as VOL's) Stored in Tbl_VOL_References This subform has subform Frm_Order_Lines (Contains line items for orders) Stored in Tbl_Order_Lines I also have a table Tbl_Rate_Card_Lookup (This contains information used to populate Tbl_Order_lines Relationships:- Tbl_LE_List is related...
0
9456
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10040
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9846
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8713
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7248
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5142
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3806
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.