Solved

How to insert a field into an exisiting table

Posted on 2011-02-13
7
368 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 119

Expert Comment

by:Rey Obrero
Comment Utility
you can use the alter statement

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

Author Comment

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

Expert Comment

by:Rey Obrero
Comment Utility
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
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
Comment Utility
I have to run this from the backend?  What about an append query?
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
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
Comment Utility
Thank you once again.  This will work out just great.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

User Beware!  This is a rather permanent solution to removing your email from an exchange server.  The only way to truly go back is to have your exchange administrator restore your mailbox from backups.  This is usually the option of last resort.  A…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
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 …

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now