i have created many tables in access for my project.
now i want the (create Tabel) query for all the table.
how to generate?. in sql server this option is available, i could not find in access
help me
thank u
11 2047 MMcCarthy 14,534
Recognized Expert Moderator MVP
You cannot create a table in Access using SQL. This is done using VBA Code and is quite complicated. The table name and field names will have to be altered each time you use it. This code is designed for use on a command button but can be adapted. -
Private Sub cmdCreateNewTable_Click()
-
Dim db As DAO.Database
-
Dim tbl As DAO.TableDef
-
Dim fld As Field
-
-
' set to the current database
-
Set db = CurrentDB
-
-
' Create a new TableDef object.
-
Set tbl = db.CreateTableDef("tableName")
-
Set fld = tbl.CreateField("MyStringField", dbText, 75)
-
tbl.Fields.Append fld
-
Set fld = tbl.CreateField("MyNumberField", dbDouble)
-
tbl.Fields.Append fld
-
Set fld = tbl.CreateField("MyDateTimeField", dbDate)
-
tbl.Fields.Append fld
-
-
' Add the new table to the database.
-
db.TableDefs.Append tbl
-
Set db = Nothing
-
-
End Sub
-
i have tables allredy but now i want the query for the the created table.
in sql server we have options like right click on the tabel -> generate sql ->
it will give a sql file with query.
so if i want to creata tables in some other data base . just i can run the query
like this . this is my need
thanks for replay
Denburt 1,356
Recognized Expert Top Contributor
I don't think we understand the question... In the MS Access database window you can click on the query tab then click new and you will see a wizard that pops up and offers a variety of choices depending on what you want. I think what you are looking for is the simple query wizard. If you are looking to create the same tables in another database simply create a new DB and drag them right on over.
i donot get u r point about (query tab) in ms access
can u give more explanation
Denburt 1,356
Recognized Expert Top Contributor
Buttons sorry, on the left hand side of the Database Window they have the buttons, tables, queries, Forms, etc.
yes we have but we can't get
"Create Table tablename (
feild datatype length,
)"
like this query for the created table
thank for replay
thank u
Denburt 1,356
Recognized Expert Top Contributor
CREATE TABLE MyTable (ProductName Text, ProductDate Date)
thanks for replay
yes this query has to be generated by access for created table
thank u
Denburt 1,356
Recognized Expert Top Contributor
The create table method in MS Access will not like the following (fld.Type) in the below code, you will need to setup a select statement or something to determine what number signifies what each field type is. Hope this steers you in the right direction. -
Dim tdf, fld
-
Dim dbs, strFldNme
-
Set dbs = CurrentDb
-
For Each tdf In dbs.TableDefs
-
If Left(tdf.Name, 4) <> "Msys" Then
-
ReDim myArray(tdf.Fields.Count)
-
For Each fld In tdf.Fields
-
strFldNme = strFldNme & fld.Name & " " & [b]fld.Type[b] & ","
-
Next
-
strFldNme = Left(strFldNme, Len(strFldNme) - 1)
-
Debug.Print "CREATE TABLE " & tdf.Name & "(" & strFldNme & ")"
-
-
End If
-
Next
-
thank for replay
i shall try that.
thanks in advance
Denburt 1,356
Recognized Expert Top Contributor
Your quite welcome, let us know how you do.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: nospam1001 |
last post by:
Environment is MySQL 3.23.33, PHP Version 4.3.2.
Have included a couple of extra columns here in an attempt to clarify what
I am trying to do. In the table rid is a unique, auto-increment. The...
|
by: mo |
last post by:
I need to bring the ssn's into UniqueSups (supervisors) from
tblNonNormalized. My inherited DB is not normalized and I find it
extremely irritating due to the workarounds needed.
I created...
|
by: paii |
last post by:
I have a table that stores job milestone dates. The 2 milestones I am
interested in are "Ship Date" TypeID 1 and "Revised Ship Date" TypeID 18.
All jobs have TypeID 1 only some jobs have TypeID 18....
|
by: Rolan |
last post by:
There must be a way to enhance the performance of a query, or find a
plausible workaround, but I seem to be hitting a wall. I have tried a
few tweaks, however, there has been no improvement.
...
|
by: Maxi |
last post by:
There is a lotto system which picks 21 numbers every day out of 80
numbers.
I have a table (name:Lotto) with 22 fields (name:Date,P1,P2....P21)
Here is the structure and sample data:
...
| |
by: travismorien |
last post by:
I have four tables of different "entities". One table contains
information for "people", one for "trusts", one for "companies" and one
for "self managed super funds". Each type of entity has an...
|
by: John T Ingato |
last post by:
If I run a query that calculates the sales data for all the inventory level
in a table, how do I go about saving that sales data into a permanent table?
I plan I using this sales data often, and...
|
by: LMHelper |
last post by:
How do I create a table from a query that will UPDATE each time I update the original table?
I created a table from a query and it stayed the same for the past couple of months and did not...
|
by: Sinner |
last post by:
Hi,
I have a field name 'USER' in tableMAIN.
How do I replace the user names with corresponding user names. I can
do that in xl using vlookup but now I'm trying to find a way to do
that in...
|
by: beacon |
last post by:
Hi everybody,
I created a database that links one table from an ODBC data source. I saved my password and UID to the data source so neither myself nor anyone else would have to login each time...
|
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...
| |
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,...
|
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...
|
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...
|
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,...
|
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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |