Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

create a new table by VBA code in another ms access database

Posted on 2008-10-10
5
Medium Priority
?
1,350 Views
Last Modified: 2013-11-27
Hi:
I am in a Database1
I need to create this table in a Database2
Table name ReportDB
Column# 1 : ReportNo  Numeric long
Column# 2 : ReportName Text 250
Column# 3 : ReportDesc Text 250
Column# 4 : RepValue Numeric long
Column# 5 : QueryName Text 250
Column# 6 : QueryDate date/time
Column# 7 : QueryRemarks memo
Column# 8 : QueryStatus Boolean

Pleas
0
Comment
Question by:Mohammad Alsolaiman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 1000 total points
ID: 22689262
try this code
Sub createTable(dbPath As String)
Dim db As DAO.Database
Set db = OpenDatabase(dbPath)
Dim sql As String
sql = "CREATE TABLE ReportDB"
sql = sql & "( "
sql = sql & "   ReportNo        LONG, "
sql = sql & "   ReportName      TEXT(250), "
sql = sql & "   ReportDesc      TEXT(250), "
sql = sql & "   RepValue        LONG, "
sql = sql & "   QueryName       TEXT(250), "
sql = sql & "   QueryDate       DATETIME, "
sql = sql & "   QueryRemarks    MEMO, "
sql = sql & "   QueryStatus     YESNO "
sql = sql & ")"
db.Execute sql
db.Close
 
End Sub

Open in new window

0
 
LVL 1

Assisted Solution

by:EXTRHMAN
EXTRHMAN earned 400 total points
ID: 22689308
Here is a link to one possible solution.

http://msdn.microsoft.com/en-us/library/bb177893.aspx

0
 

Author Comment

by:Mohammad Alsolaiman
ID: 22690149
Hi:
Wonderful
Ok
Actually I have the same table in database1, contains data.
And I need to fill in the new table I just create it in database2 with the same data in database1.
In other word , I need to copy the table structure with the data in it from database1 to database2.
Is it possible to do so.
Pleas
0
 
LVL 26

Assisted Solution

by:dannywareham
dannywareham earned 600 total points
ID: 22698229
Of course.
You can create a table with:

Dim mySQL as String
mySQL = "INSERT INTO mynewtable FROM yourtable"
DoCmd.RunSQL mySQL
0
 

Author Closing Comment

by:Mohammad Alsolaiman
ID: 31505121
pleas forgive me if i'm not fair
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question