Add field to table in another database

Add field to table in another database

am 07.11.2007 17:47:58 von Jim

How do I use VB to create some code behind a button in one database
that will add a field to a table in another database that is not open
at the time?

The target database is C:\NewDB\statistics.mdb
The table is QualityTracking
The field to add is WrittenUpBy, which is text, 5 characters

Any help would be appreciated.

Re: Add field to table in another database

am 07.11.2007 18:10:05 von Jana

On Nov 7, 9:47 am, Jim wrote:
> How do I use VB to create some code behind a button in one database
> that will add a field to a table in another database that is not open
> at the time?
>
> The target database is C:\NewDB\statistics.mdb
> The table is QualityTracking
> The field to add is WrittenUpBy, which is text, 5 characters
>
> Any help would be appreciated.
Jim~

This worked in my test:

Private Sub CommandButton1_Click()
Dim dbsNew As DAO.Database
Set dbsNew = DBEngine.Workspaces(0).OpenDatabase("C:\NewDB
\statistics.mdb")
dbsNew.Execute ("ALTER TABLE QualityTracking ADD COLUMN WrittenUpBy
Text(5)")
End Sub

You'll need to put in some error handling, though.

HTH,
Jana

Re: Add field to table in another database

am 07.11.2007 21:46:56 von Jim

On Nov 7, 11:10 am, Jana wrote:
> On Nov 7, 9:47 am, Jim wrote:> How do I use VB to create some code behind a button in one database
> > that will add a field to a table in another database that is not open
> > at the time?
>
> > The target database is C:\NewDB\statistics.mdb
> > The table is QualityTracking
> > The field to add is WrittenUpBy, which is text, 5 characters
>
> > Any help would be appreciated.
>
> Jim~
>
> This worked in my test:
>
> Private Sub CommandButton1_Click()
> Dim dbsNew As DAO.Database
> Set dbsNew = DBEngine.Workspaces(0).OpenDatabase("C:\NewDB
> \statistics.mdb")
> dbsNew.Execute ("ALTER TABLE QualityTracking ADD COLUMN WrittenUpBy
> Text(5)")
> End Sub
>
> You'll need to put in some error handling, though.
>
> HTH,
> Jana

Thanks Jana, it worked great!

Re: Add field to table in another database

am 07.11.2007 21:54:50 von Jana

On Nov 7, 1:46 pm, Jim wrote:
> On Nov 7, 11:10 am, Jana wrote:
>
>
>
>
>
> > On Nov 7, 9:47 am, Jim wrote:> How do I use VB to create some code behind a button in one database
> > > that will add a field to a table in another database that is not open
> > > at the time?
>
> > > The target database is C:\NewDB\statistics.mdb
> > > The table is QualityTracking
> > > The field to add is WrittenUpBy, which is text, 5 characters
>
> > > Any help would be appreciated.
>
> > Jim~
>
> > This worked in my test:
>
> > Private Sub CommandButton1_Click()
> > Dim dbsNew As DAO.Database
> > Set dbsNew = DBEngine.Workspaces(0).OpenDatabase("C:\NewDB
> > \statistics.mdb")
> > dbsNew.Execute ("ALTER TABLE QualityTracking ADD COLUMN WrittenUpBy
> > Text(5)")
> > End Sub
>
> > You'll need to put in some error handling, though.
>
> > HTH,
> > Jana
>
> Thanks Jana, it worked great!- Hide quoted text -
>
> - Show quoted text -

You're welcome :)
Jana