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!
7 10927
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
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.
just wondering if anyone has any ideas for me, please!
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
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. -
Dim MyDB As DAO.Database, MyTable As DAO.TableDef, MyField As DAO.Field
-
-
If IsNull(Me!cboTableNames) Then Exit Sub
-
-
Set MyDB = CurrentDb()
-
-
'Create a Table based on the Combo Box (cboTableNames) selection
-
Set MyTable = MyDB.CreateTableDef(Me!cboTableNames)
-
-
'Create a Field named Field1 , Text Data Type, Size 255
-
Set MyField = MyTable.CreateField("Field1", dbText, 255)
-
-
'Append the Field to the Fields Collection of the Table
-
MyTable.Fields.Append MyField
-
-
'Append the Table to the Tabledefs Collection of the Database
-
MyDB.TableDefs.Append MyTable
-
-
'Refresh to TableDefs Collection
-
MyDB.TableDefs.Refresh
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!!
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
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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....
|
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
...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |