Solved

How to insert a field into an exisiting table

Posted on 2011-02-13
7
371 Views
Last Modified: 2012-06-22
I have a few tables that I need to create two extra fields.  Here where I work it's not a problem, but the remote sites that use this don't have the expertise to do this.

What I would like is a function that checks the backend for a version and if it doesn't match then it asks to upgrade.  If the user says yes then it runs some type of code that inserts these fields into the table.

Is this possible?
0
Comment
Question by:John Sheehy
  • 4
  • 3
7 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34884975
you can use the alter statement

alter table tableX add column colA text(25),colB  text(25)
0
 

Author Comment

by:John Sheehy
ID: 34884979
Can this be used in Access 2003 and I am using the front end to update the back end?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34884991
yes, you can use the codes in A2003, but you need to access the BE to alter the table. You can not alter the table structure in the linked table from the FE
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 34885059
here is how to do this

sub alterBETable()
dim acObj as object, bePath
bepath="\\server\folder\be.mdb"
set acObj=createobject("access.application")
acobj.opencurrentdatabase  bePath
acobj.docmd.runsql "alter table tablex add column colA text(25),colB text(25)"

 
acObj.closecurrentdatabase
set acobj=nothing

end sub
0
 

Author Comment

by:John Sheehy
ID: 34885082
I have to run this from the backend?  What about an append query?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34885130
I have to run this from the backend?
Yes or you have to access the backend using codes from another db. using the codes i posted above

 What about an append query?
an append query adds records to the table
you can run an append query from the FE, appending records to the linked table
0
 

Author Comment

by:John Sheehy
ID: 34885170
Thank you once again.  This will work out just great.
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question