Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copying Table 1

Status
Not open for further replies.

lars7

Technical User
Aug 16, 2005
817
GB
Hi,
Is it possible to change the names of some fields after copying a table using copyobject. I have a table that I would like to copy so that I can change some of the field names because they where giving names with gaps in them and I cant put them in code like; "fwd for match" and the table is called "trust staff". I have copied the table and renamed it "tbltruststaff" at the start of an onclick command to create a query on the fly:

DoCmd.CopyObject "J.E.D new..mdb.", "tbltruststaff", acTable, "trust staff"

This works fine but I was wondering if I could change the field names before the rest of the code is run.




 
How about (?):
Code:
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field

Set db = CurrentDb
Set tdf = db.TableDefs("tblTable1")
For Each fld In tdf.Fields
    fld.Name = Replace(fld.Name, " ", "")
Next

I don't quite get I cant put them in code like; "fwd for match"? Maybe "[fwd for match]"?
 
Hi again Ramou,

When I put the field name like:

strfwd for match

I got the error red wording.

Your coding worked great for the new table after I figured out where to put it. Thanks again for your help, I'm quiet new to this and don't always explain things properly but I'm learning more all time.

Cheers,

Tom.




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top