473,399 Members | 2,159 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Add Field to Table using Access Macro

Hi,

Is there a way to add a permanent field to a table using a macro? I have a number of different tables that I need to add the same field name to, then I update that field based on info in the table, and append them all into one big table. It would be very helpful if I didn't have to go into the design view of each table to add these fields. I'm a novice when it comes to code, but any help would be greatly appreciated!!

Thanks in advance!
Feb 27 '07 #1
2 7538
nico5038
3,080 Expert 2GB
For this you can use a so-called ALTER TABLE query.
When you need to do this for multiple tables you'll need however to grasp the tabels from the currentdb's tabledefs and execute that DDL query in a VBA loop.
The tables will however need to be indentifyable and in general it's faster to do this with a copy/paste (Ctrl+C and Ctrl+V) when selecting the whole line with the field definition in the tabledesign mode.....

Nic;o)
Feb 28 '07 #2
ADezii
8,834 Expert 8TB
Hi,

Is there a way to add a permanent field to a table using a macro? I have a number of different tables that I need to add the same field name to, then I update that field based on info in the table, and append them all into one big table. It would be very helpful if I didn't have to go into the design view of each table to add these fields. I'm a novice when it comes to code, but any help would be greatly appreciated!!

Thanks in advance!
This could easily be done with a Macro:
__1 The Macro calls a Public Function
__2 Within this Function is VBA code usin DAO that dynamically creates the Field within the specified Table.

If you wish to continue along this line, please give me more information such as:
__1 The Table Name to contain the newly created Field
__2 The Field Data Type, Size, etc
__3 Any other Parameters that you could think of.
Mar 1 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: BlackFireNova | last post by:
This concerns an Access 2002 (XP) database. There are two fields, "Notes" (Memo Field) and "Notes Update" on a form (among others) which I am concerned with here. Problem: I need to be able...
4
by: Andy Hutchings | last post by:
Hi everybody - hope you can help out here. I have a form in a database, which is a columnar form from one of the tables in the db - there is a sub-form to the form which is a datasheet view of...
16
by: Georges Heinesch | last post by:
Hi. My form contains a control (cboFooBar), which has an underlying field with the "Required" property set to "Yes". Now, while filling out all the controls of the form, I have to fill out this...
2
by: steve.turner | last post by:
Hi all, I'm hoping someone can stop me tearing (what's left of) my hair out over this problem... I have a linked Excel file from which I append the data to an empty local Access table. I...
1
by: Curtis | last post by:
I am having a problem with the coding below that someone was trying to help me with in another website. I have been to several websites and hopefully here I can get it resolved. I inherited this...
2
by: Brett | last post by:
My database has 2 tables: Table1 & Table2. If a field is not null on a record in table2, then the not null fields in table1 that correspond to the records in table1 needs to be updated to match the...
1
by: lorirobn | last post by:
Hi, I have been manually importing a text file on a weekly basis to an Access table. The data on one field is about to change (happens to be the first field). It was numeric, and is defined as...
8
by: CaptainCrazyHat | last post by:
Greetings! I currently have a table named 2008-01-30. I would like to insert a new field, and I would like that field to be in a Date format and have it populated with the table name. I'll be...
1
by: bytes access nubie | last post by:
Hello. I'm trying to create one macro in Access 2003 that will delete a field (called ID) in a table. I then need a separate macro that will *add* a field back in called ID w/type of autonumber. I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.