By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,509 Members | 2,185 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,509 IT Pros & Developers. It's quick & easy.

Altering tables in code

P: n/a
I wish to be able to do some things to tables in code.

1. Add a field and its properties.
2. Alter the properties of an existing field in a table.
3. Append some extra entries onto the bottom of a table, if they are not
already there.

Any help would be appreciated.

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


P: n/a
Br
Dixie <di***@dogmail.com> wrote:
I wish to be able to do some things to tables in code.

1. Add a field and its properties.
2. Alter the properties of an existing field in a table.
Lookup the help on the Tabledef oject.
3. Append some extra entries onto the bottom of a table, if they are
not already there.
Search for the record. If it doesn't exist then add it.

eg. (very simplified DAO example)

myRS.FindNext "[myID] = 1"
If myRS.NoMatch then
myRS.AddNew
myRS![myID] = 1
myRS.Update
End If
Any help would be appreciated.

dixie

--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response
Nov 13 '05 #2

P: n/a
Had a quick look at the help file, but it is mainly about creating new
tabledef objects and I don't want to iterate through the tabledef
collection.

Say there was already a table in the database called 'MyTable' and I wanted
to add a field called MyNewField and then say set it as a text field of 25
characters. How do I do that in code.

dixie

"Br@dley" <n0****@4u.com> wrote in message
news:Pe*****************@news-server.bigpond.net.au...
Dixie <di***@dogmail.com> wrote:
I wish to be able to do some things to tables in code.

1. Add a field and its properties.
2. Alter the properties of an existing field in a table.


Lookup the help on the Tabledef oject.
3. Append some extra entries onto the bottom of a table, if they are
not already there.


Search for the record. If it doesn't exist then add it.

eg. (very simplified DAO example)

myRS.FindNext "[myID] = 1"
If myRS.NoMatch then
myRS.AddNew
myRS![myID] = 1
myRS.Update
End If
Any help would be appreciated.

dixie

--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response

Nov 13 '05 #3

P: n/a
Br
Dixie <di***@dogmail.com> wrote:
Had a quick look at the help file, but it is mainly about creating new
tabledef objects and I don't want to iterate through the tabledef
collection.

Say there was already a table in the database called 'MyTable' and I
wanted to add a field called MyNewField and then say set it as a text
field of 25 characters. How do I do that in code.

dixie
You don't need to iterate through the collection...

eg. CurrentDB.TableDefs("tblMyTable").Fields("myField" )
"Br@dley" <n0****@4u.com> wrote in message
news:Pe*****************@news-server.bigpond.net.au...
Dixie <di***@dogmail.com> wrote:
I wish to be able to do some things to tables in code.

1. Add a field and its properties.
2. Alter the properties of an existing field in a table.


Lookup the help on the Tabledef oject.
3. Append some extra entries onto the bottom of a table, if they are
not already there.


Search for the record. If it doesn't exist then add it.

eg. (very simplified DAO example)

myRS.FindNext "[myID] = 1"
If myRS.NoMatch then
myRS.AddNew
myRS![myID] = 1
myRS.Update
End If
Any help would be appreciated.

dixie

--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response


--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response
Nov 13 '05 #4

P: n/a
rkc
Dixie wrote:
Had a quick look at the help file, but it is mainly about creating new
tabledef objects and I don't want to iterate through the tabledef
collection.

Say there was already a table in the database called 'MyTable' and I wanted
to add a field called MyNewField and then say set it as a text field of 25
characters. How do I do that in code.


CurrentDb.Execute ("ALTER TABLE MyTable ADD MyNewField Text 25")
Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.