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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating names of fields in a tabledef dynamicaly

Status
Not open for further replies.

lanelouna

Programmer
Dec 19, 2002
71
GB
hello
I hope someone can help me on this
i am trying to create fields in a tabledef
but the name of the fields is created dynamically
is it possible
here is an example of what i am trying todo nd obviously it does not work
thanks in advance for your suggestions and help
Lina

Do While (i < nbrChamps)
j = i +1
Set chp3 = dft.CreateField(["n" & j ], dbInteger, 3)
Set chp4 = dft.CreateField(["rt" & k ], dbInteger, 3)
dft.Fields.Append chp3
dft.Fields.Append chp4
i = i + 2
Loop
 
or can i do something similar?
it is not working i know
but somethign similar

dim fieldname1 as string
dim fieldname2 as string

Do While (i < nbrChamps)
j = i + 1
fieldname1 = "n " & i
fieldname2 = "rt " & j
Set chp3 = dft.CreateField(fieldname1, dbInteger, 3)
Set chp4 = dft.CreateField(fieldname2, dbInteger, 3)
dft.Fields.Append chp3
dft.Fields.Append chp4
i = i + 2
Loop
thanks in advance for your help
Lina
 
well it is working
sorry to have bothered you with this :)
should have used []
Set chp3 = dft.CreateField([fieldname1], dbInteger, 3)
anyways thanks
Lina
 
Can't see the problem here, now.
Are you sure that dft and nbrChamps are OK and you are appending the table to the database?
 
lol
:)
when there is a will there is a way
u ll get there someday
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top