Solved

Add field to existing table MS Access

Posted on 2008-09-30
1
515 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
1 Comment
 
LVL 9

Accepted Solution

by:
cdbeste earned 50 total points
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now