Home > Archive > Visual Basic > August 2005 > Adding a new field in MSAccess DB ( newbie )
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Adding a new field in MSAccess DB ( newbie )
|
|
| Arthur Fouls 2005-08-25, 6:55 pm |
| Hi All,
Sorry i was wondering if you coudl kindly help a newbie to this group or
point me in the right direction.
I am trying to add an extra filed with vb code to my msaccess database which
currently has 20 fields.
The new field i want to add is called `Help` and just needs to be a normal
text field.
any ideas?
Thanks very much
Arthur.
PS
Also is it possible to change a field type by vb code, say from text to
date ?, if so how?
| |
|
| The ALTER TABLE Sql statement will do it for you:
ALTER TABLE TABLE_NAME
{ADD
{COLUMN field type[(size)] [NOT NULL] [CONSTRAINT index] |
CONSTRAINT multifieldindex} |
DROP {COLUMN field | CONSTRAINT indexname} }
Check out the SQL Guide at the bottom of:
http://www.veign.com/vrc_app_main.asp
--
Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
http://www.veign.com/vrc_main.asp
--
"Arthur Fouls" <arthur@fouls.com> wrote in message
news:ExlPe.145051$uo4.134711@fe01.news.easynews.com...
> Hi All,
>
> Sorry i was wondering if you coudl kindly help a newbie to this group or
> point me in the right direction.
>
> I am trying to add an extra filed with vb code to my msaccess database
which
> currently has 20 fields.
>
> The new field i want to add is called `Help` and just needs to be a normal
> text field.
>
> any ideas?
>
> Thanks very much
>
> Arthur.
>
> PS
>
> Also is it possible to change a field type by vb code, say from text to
> date ?, if so how?
>
>
| |
| Dr. Edward Warren 2005-08-27, 9:56 pm |
| The field you wish to add is probably in a table with 20 fields. Do not do
it in VB code at all. Open the table in design mode and add the new field
at the bottom of the list. It will then be available to all of your forms
and queries for manipulation.
To change a field from text to date, I would also do this directly. I would
create a new date field in design mode. Then open the table and copy all of
the text data into the new date field and see if it converts successfully.
This is done by selecting all of of the text field and then copying it; then
select the first cell of the date field and paste. If the formatting does
not allow conversion,
then you may need to create a form that examines the text field one record
at a time, determines the appropriate date, and inserts it into the
corresponding date field.
This is all stuff that needs to be done only once, so incorporating it into
code makes little sense unless it is a learning exercise. If I wanted to do
it in code
I would write a make table query. First generate it by using the query
wizard. The text field would be CDate(textfieldname) to convert it into a
date.
Sincerely yours,
Edward Warren
"Arthur Fouls" <arthur@fouls.com> wrote in message
news:ExlPe.145051$uo4.134711@fe01.news.easynews.com...
> Hi All,
>
> Sorry i was wondering if you coudl kindly help a newbie to this group or
> point me in the right direction.
>
> I am trying to add an extra filed with vb code to my msaccess database
which
> currently has 20 fields.
>
> The new field i want to add is called `Help` and just needs to be a normal
> text field.
>
> any ideas?
>
> Thanks very much
>
> Arthur.
>
> PS
>
> Also is it possible to change a field type by vb code, say from text to
> date ?, if so how?
>
>
|
|
|
|
|