Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to insert a field into an exisiting table

Posted on 2011-02-13
7
Medium Priority
?
377 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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

916 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