473,785 Members | 2,283 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Possible to write a macro that creates a new table?

27 New Member
Hello,

Is it possible to write/record a macro in Access that would create a new table?

The new table's name would be assigned based on the current value in one of the combo boxes in the form, and the new table would only need to be one column.

Thanks!
Feb 15 '08 #1
7 10987
MindBender77
234 New Member
Hello,

Is it possible to write/record a macro in Access that would create a new table?

The new table's name would be assigned based on the current value in one of the combo boxes in the form, and the new table would only need to be one column.

Thanks!
I believe what you are asking could be done using a "MakeTable Query".

Bender
Feb 15 '08 #2
seagullino
27 New Member
thanks..perhaps I was unclear in my original post...

I want to have, let's say, a button on a form that, when clicked, creates and opens a new table that is named after the active selection in a combo box that is also on this form.
Feb 15 '08 #3
seagullino
27 New Member
just wondering if anyone has any ideas for me, please!
Feb 18 '08 #4
FishVal
2,653 Recognized Expert Specialist
Hi, there.

You may use
  • SQL: either SELECT ... INTO (to create table using query as a template) or CREATE TABLE (to create table from scratch)
  • VBA: TableDefs collection (somewhat more sophisticated technique)

Just out of curiosity, what a very special reason you have to create tables with button clicks?

Regards,
Fish
Feb 18 '08 #5
ADezii
8,834 Recognized Expert Expert
just wondering if anyone has any ideas for me, please!
Yes, it can be done, and here is perhaps the simplest Method. I'll post it, but I'm with FishVal on this one, just wandering why you would want to do this.
Expand|Select|Wrap|Line Numbers
  1. Dim MyDB As DAO.Database, MyTable As DAO.TableDef, MyField As DAO.Field
  2.  
  3. If IsNull(Me!cboTableNames) Then Exit Sub
  4.  
  5. Set MyDB = CurrentDb()
  6.  
  7. 'Create a Table based on the Combo Box (cboTableNames) selection
  8. Set MyTable = MyDB.CreateTableDef(Me!cboTableNames)
  9.  
  10. 'Create a Field named Field1 , Text Data Type, Size 255
  11. Set MyField = MyTable.CreateField("Field1", dbText, 255)
  12.  
  13. 'Append the Field to the Fields Collection of the Table
  14. MyTable.Fields.Append MyField
  15.  
  16. 'Append the Table  to the Tabledefs Collection of the Database
  17. MyDB.TableDefs.Append MyTable
  18.  
  19. 'Refresh to TableDefs Collection
  20. MyDB.TableDefs.Refresh
Feb 19 '08 #6
seagullino
27 New Member
thank you for the help! I will give this a try and see if I can get it to work (I'm new to the coding, but I think I can struggle with it long enough to make it happen).

here is the application, which you were asking about:

our office has to complete certain tasks on individuals who have responded to an invitation. normally, we have to manually screen each responder to see if they meet the criteria that warrants action on our part. I have designed a simple form-based tool with one fields and a button.

The first field is a combo box that is populated with all of the active events. The user selects the event on which they are working and presses the submit button which opens a run-query macro and returns a list of responded invitees requiring action. Very simple tool, saves a lot of time.

The new feature that I'm trying (with this post) to implement is this: I'd like to make it possible for the user to enter the ID numbers of the invitees for which action has already been taken - sort of a checklist of who they've already done. This list of completed IDs would then be omitted from the results the next time someone select an event and runs the query. I figured that by having a table of completed IDs, that table could be worked into the query/macro in a way that would omit those from the results.

I'm sure there must be a more elegant way to do this (and I'm open to your ideas), but this was one idea I had.

Thank you!!
Feb 19 '08 #7
Scott Price
1,384 Recognized Expert Top Contributor
A more elegant approach ( and one conforming to Database Normalisation Rules ) would be to include a field in your existing table that holds Completed Yes/No data.

Then your query could simply exclude those entries that are marked as Completed Yes by a simple WHERE [tableX].[CompletedField] = No criteria statement.

Regards,
Scott
Feb 19 '08 #8

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

Similar topics

4
2311
by: Bon | last post by:
Hello all Would it be possible to migrate the MS Access 2000 to MS SQL Server 2000? My application is using MS Access 2000 as database and as user interface such as forms. Now, I want to migrate the backend database from MS Access 2000 to MS SQL Server 2000. However, I want to keep the MS Access 2000 interface. Would it be possible?
1
2208
by: Deano | last post by:
Hi, I need to disable a command button at some point. Easy enough. Initially in design view it is set as enabled. Now once I disable it, how can I ensure that when the app is restarted, the Enabled property in design view is now set to disabled (i.e Enabled = No). I don't want to track this using a flag in a table if at all possible and the final app is an MDE. I suspect this can't be done but any comments
7
23555
by: Newbie_sw2003 | last post by:
Where should I use them? I am giving you my understandings. Please correct me if I am wrong: MACRO: e.g.:#define ref-name 99 The code is substituted by the MACRO ref-name. So no overhead. Execution is faster. Where will it be stotred?(Is it in bss/stack/?) FUNCTION:
8
1382
by: Thorsten Ottosen | last post by:
Dear all, I'm new to C#, so forgive my stupid question. In my question to avoid boilerplate code, I was wondering if I could use attributes to generate some code for me. For example public class Foo
7
23554
by: fei.liu | last post by:
#define ONCFILE_ERR1(funcname, name) \ { \ #ifdef DEBUG\ cerr << __FILE__ << ":" << __LINE__ << " duplicated call to " << funcname << " " << name << endl; \ #endif \ } I want to have conditional macros inside a macro. When I compile this
6
6438
by: Takeadoe | last post by:
Dear NG, Can someone assist me with writing the little code that is needed to run an update table query each time the database is opened? From what I've been able to glean from this group, the Autoexec Macro looks like the way to go. Could someone please assist? Thank you very much! Mike
5
3491
by: Bill | last post by:
This database has no forms. I am viewing an Access table in datasheet view. I'd like to execute a macro to execute a function (using "runcode"). In the function, I'll reading data from the record the cursor was on in the datasheet at the time I executed the macro. So, the questions are: 1) In the macro, how to I get my hands on the record key or record data of the record the cursor was on in the datasheet at the time I executed the...
0
3479
by: acarrazco | last post by:
Hello, I am totaly new to VBA and I'm trying to modify a macro that was given to me but it doesn't seem to be working. I'm trying to extract data from three excel spreadsheets, put it into a combined one which creates a pivot table and sorts it into different fromats. Here is the code, can any body help? Sub Update_Land_Actuals() On Error Resume Next If InputBox("Enter password to continue", "Centex Homes") <> "***" Then Exit Sub...
3
1476
by: thinktwice | last post by:
i want to define a macro like #define STRING2(x) #x #define STRING(x) STRING2(x) #define PROMPT(x) #pragma message(__FILE__ "(" STRING(__LINE__) "):" STRING(x)) <---- compile failed i want to use this macro to remind me that something need to be done but not done yet. is it possible to write such a macro??
0
9646
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9483
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10346
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10157
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10096
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8982
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7504
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4055
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2887
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.