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

Adding fields to a table

Status
Not open for further replies.

eojhan

Technical User
Jun 21, 2002
5
US
I'm a little confused.

I was able to get my last bit of code to work (replacing spaces with nothing- thanks to all who helped) but now I am running into another problem.

I wish to add a field to a table in the current database. I tried using the append method from the sample code, but am having some difficulty.

1. The variables dimmed in the code are appearing as user-defined types (Database and TableDef) Why is it breaking on this? Do I need to define these? If I do then the example code should have said so...

2. I just went ahead and dimmed them as objects. Then the code breaks on:

.Fields.Append .CreateField("TextField", dbText)

giving me a data type conversion. My guess is because I didn't define the object type. Could someone help me out with this? I assume this should be an easy one for an experienced programmer.

Thanks

Owen
 
Nevermind. I figured out what the problem was. I didn't have the correct type library set.
 
You know...I like SQL much better for this type of thing. For me it's easier to use and it's much more portable (at least conceptually):

strSQL = "ALTER TABLE YourTable ADD ColName Text(30)"

DoCmd.RunSQL strSQL

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top