Results 1 to 4 of 4
  1. #1
    dododo is offline Novice
    Windows Vista Access 2003
    Join Date
    Jun 2011
    Posts
    26

    Create table/table name from textbox

    Hi,

    I'm trying to create table in my access database that would have name like i type in Textbox and than i have to click the button

    With code like this :
    Private Sub Command0_Click()
    Dim strsql
    strsql = "create table '" & txttablename.Value & "' ( id integer , gender char(1) default ""F"");"
    CurrentProject.Connection.Execute strsql


    CurrentProject.Connection.Close
    Me.Application.RefreshDatabaseWindow
    End Sub

    **Note: txttablename is the name of my textbox

    I got error. Please help me to correct it.

  2. #2
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    1) What exactly does the error say?
    2) use either msgbox or debug.print to print out your SQL. Read it and see if there is an obvious error.
    3) Is "Char(1)" a valid field type in Access? Probably should be Text.

  3. #3
    dododo is offline Novice
    Windows Vista Access 2003
    Join Date
    Jun 2011
    Posts
    26
    Quote Originally Posted by dododo View Post
    Hi,

    I'm trying to create table in my access database that would have name like i type in Textbox and than i have to click the button

    With code like this :
    Private Sub Command0_Click()
    Dim strsql
    strsql = "create table '" & txttablename.Value & "' ( id integer , gender char(1) default ""F"");"
    CurrentProject.Connection.Execute strsql
    CurrentProject.Connection.Close
    Me.Application.RefreshDatabaseWindow
    End Sub

    **Note: txttablename is the name of my textbox

    I got error. Please help me to correct it.
    thanks. Now i can do it.

  4. #4
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    1) Please post what solved the problem, so that others can learn from the solution.

    2) Please mark the thread "solved". Top of page, under "thread tools".

    Thanks!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 03-28-2013, 07:22 AM
  2. Replies: 3
    Last Post: 10-02-2012, 12:25 PM
  3. Replies: 5
    Last Post: 05-02-2012, 07:56 AM
  4. Replies: 2
    Last Post: 12-20-2011, 07:33 AM
  5. Replies: 1
    Last Post: 12-16-2011, 08:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums