473,473 Members | 1,962 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to get query of created table

60 New Member
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
Mar 20 '07 #1
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.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdCreateNewTable_Click()
  2. Dim db As DAO.Database
  3. Dim tbl As DAO.TableDef
  4. Dim fld As Field
  5.  
  6.    ' set to the current database
  7.    Set db = CurrentDB
  8.  
  9.    ' Create a new TableDef object.
  10.    Set tbl = db.CreateTableDef("tableName")
  11. Set fld = tbl.CreateField("MyStringField", dbText, 75)
  12. tbl.Fields.Append fld
  13. Set fld = tbl.CreateField("MyNumberField", dbDouble)
  14. tbl.Fields.Append fld
  15. Set fld = tbl.CreateField("MyDateTimeField", dbDate)
  16. tbl.Fields.Append fld
  17.  
  18. ' Add the new table to the database.
  19.    db.TableDefs.Append tbl
  20.    Set db = Nothing
  21.  
  22. End Sub
  23.  
Mar 22 '07 #2
joerozario
60 New Member
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
Mar 22 '07 #3
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.
Mar 22 '07 #4
joerozario
60 New Member
i donot get u r point about (query tab) in ms access

can u give more explanation
Mar 23 '07 #5
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.
Mar 23 '07 #6
joerozario
60 New Member
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
Mar 26 '07 #7
Denburt
1,356 Recognized Expert Top Contributor
CREATE TABLE MyTable (ProductName Text, ProductDate Date)
Mar 26 '07 #8
joerozario
60 New Member
thanks for replay

yes this query has to be generated by access for created table

thank u
Mar 27 '07 #9
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.

Expand|Select|Wrap|Line Numbers
  1. Dim tdf, fld
  2. Dim dbs, strFldNme
  3. Set dbs = CurrentDb
  4. For Each tdf In dbs.TableDefs
  5. If Left(tdf.Name, 4) <> "Msys" Then
  6. ReDim myArray(tdf.Fields.Count)
  7.     For Each fld In tdf.Fields
  8.         strFldNme = strFldNme & fld.Name & " " & [b]fld.Type[b] & ","
  9.     Next
  10. strFldNme = Left(strFldNme, Len(strFldNme) - 1)
  11. Debug.Print "CREATE TABLE " & tdf.Name & "(" & strFldNme & ")"
  12.  
  13. End If
  14. Next
  15.  
Mar 27 '07 #10
joerozario
60 New Member
thank for replay

i shall try that.

thanks in advance
Mar 28 '07 #11
Denburt
1,356 Recognized Expert Top Contributor
Your quite welcome, let us know how you do.
Mar 29 '07 #12

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

Similar topics

0
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...
6
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...
6
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....
15
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. ...
8
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: ...
1
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...
2
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...
3
LMHelper
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...
9
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...
11
beacon
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...
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
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
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...
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
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,...
1
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.