Solved

Add field to existing table MS Access

Posted on 2008-09-30
1
525 Views
Last Modified: 2012-05-05
Hello,

With attached code snippet. How can I add a new field to an existing table?

Regards,
Dennis
Private Sub Command1_Click()
Dim dbbiblio As Database
Dim rds As Recordset
Set dbbiblio = OpenDatabase("C:\Program Files\Microsoft Visual Studio\VB98\biblio.mdb")
Set rswholetable = dbbiblio.OpenRecordset("Select * from Titles order by title")
 
Do Until rswholetable.EOF = True
Debug.Print rswholetable.Fields("Title") & rswholetable.Fields("ISBN")
rswholetable.MoveNext
Loop
 
 rswholetable.AddNew
    rswholetable.Fields("Title") = "dennis"
    rswholetable.Fields("ISBN") = 1234
    rswholetable.Fields("PubID") = 1
    rswholetable.Update

Open in new window

0
Comment
Question by:Schuttend
[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
1 Comment
 
LVL 9

Accepted Solution

by:
cdbeste earned 50 total points
ID: 22608007
try something like this....

Private Sub cmdAddColumn_Click()
    Dim curDatabase As Object
    Dim tblStudents As Object
    Dim colFullName As Object

    ' Get a reference to the current database
    Set curDatabase = CurrentDb
    ' Get a reference to a table named Customers
    Set tblStudents = curDatabase.TableDefs("Students")
   
    Set colFullName = tblCustomers.CreateField("FullName", DB_TEXT)
    tblCustomers.Fields.Append colFullName
End Sub
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month6 days, 19 hours left to enroll

622 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