Results 1 to 7 of 7
  1. #1
    hyperionfall is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    mississippi
    Posts
    18

    create new column-name it from form field

    is there a way to create a new table and have it named from a field of a form such that the user can create the table and select the name from a dropdown or type in the name. the table needs to be created from a form function as well because the user will have no access to the design features its just a user control panel basically.
    can this also be done with adding columns to a table.



    thanks so much

    lee

  2. #2
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    https://www.accessforums.net/forms/a...form-3936.html

    Follow this link. I had posted this some times back.

    If this solves your problem please mark the thread solved.

  3. #3
    hyperionfall is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    mississippi
    Posts
    18
    thanks i will give it a try once i get into my office later today.

  4. #4
    hyperionfall is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    mississippi
    Posts
    18
    """I found the question very interesting and this is how you can do it.
    I have a table called Table1
    I have a Form called Form1
    I have three text boxes in it
    textBox1=you will type your Table name in it e.g. Table1
    textbox3=you will type the field name you want to create e.g. Salary,Employee_Name
    textbox5=you will type the field datatype e.g. Text, Number, Auto Number.
    Command button 0=in its OnClick event you will type the following code:
    Private Sub Command0_Click()
    Dim TableName As String
    Dim ColumnName As String
    Dim Datatype As String
    Dim MasterSQL As String

    TableName = "ALTER TABLE" & " " & Me.Text1
    ColumnName = "ADD COLUMN" & " " & Me.Text3
    Datatype = Me.Text5 & ";"

    MasterSQL = TableName & " " & ColumnName & " " & Datatype
    DoCmd.RunSQL MasterSQL

    End Sub




    this is what i found on your other post. it looks like i can use that. was just wondering, i am not very code savy so here is my question.

    where there is Me.XXXX to call the current form can i replace the Me to call a foriegn form. if so what would the syntax be? would it be Forms![formname].text1?

    thanks

  5. #5
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    it will be Forms!Name of the Form!Name of the Field. this will be the syntax

  6. #6
    hyperionfall is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    mississippi
    Posts
    18
    Thanks it worked awsome.
    could you rename a table using this method?
    i tried
    Private Sub Command32_Click()
    Dim TableName As String
    Dim newname As String
    Dim MasterSQL As String
    TableName = "ALTER TABLE" & " " & Me.oldname
    newname = "RENAME TO" & " " & Me.newname & ";"
    MasterSQL = TableName & " " & newname
    DoCmd.RunSQL MasterSQL
    End Sub

    but it gave me syntax errors

  7. #7
    hyperionfall is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    mississippi
    Posts
    18
    got it...used docmnd.rename instead

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

Similar Threads

  1. Replies: 3
    Last Post: 02-17-2010, 02:29 PM
  2. Urgent issue! Create field for intervals
    By Bjorn in forum Queries
    Replies: 3
    Last Post: 02-10-2010, 10:26 AM
  3. Replies: 7
    Last Post: 12-30-2009, 11:03 AM
  4. How to Create Field in Template
    By Jonathan in forum Access
    Replies: 1
    Last Post: 01-30-2009, 02:00 PM
  5. inserting values in column based another column
    By wasim_sono in forum Database Design
    Replies: 1
    Last Post: 06-27-2006, 05:23 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