Results 1 to 3 of 3
  1. #1
    vCallNSPF is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Dec 2009
    Posts
    49

    "Add a new field" form

    is there a way to add fields to a table through the use of a form?



    after thats done is it possible to then automatically add this field to a query based on this table?

  2. #2
    maximus's Avatar
    maximus is offline Expert
    Windows XP Access 2003
    Join Date
    Aug 2009
    Location
    India
    Posts
    931

    Adding Fields using a form.

    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 should do the trick.
    if your problem is solved please mark the thread as solved

  3. #3
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    I am just curious whether you were able to solve your problem if yes please mark this thread solved as then it will help someone else with the same problem find a solution easily.
    thanx

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

Similar Threads

  1. Error message and How do I find the "value Field" ?
    By createdwithfire in forum Forms
    Replies: 1
    Last Post: 11-05-2009, 12:26 PM
  2. Replies: 3
    Last Post: 10-20-2009, 06:56 AM
  3. aSTR = Dir("C:\*.*") >> "Type Mismatch"
    By JGrant in forum Programming
    Replies: 1
    Last Post: 03-28-2009, 05:17 AM
  4. Replies: 2
    Last Post: 08-31-2006, 12:19 PM
  5. "Count" and "Countif" in Reports
    By JMantei in forum Reports
    Replies: 1
    Last Post: 06-20-2006, 02:20 PM

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