Results 1 to 2 of 2

Thread: saving data to access?? help please

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2000
    Posts
    81
    hi everyone im recently new to vb and would like to know how i would save data from my vb application into an access
    database i know how to acces the data but not how to
    save data into access database help help??
    here is my code to look at my data??

    general declarations
    Dim db As Database
    Dim rs As Recordset



    Private Sub Command1_Click()
    Set db = OpenDatabase("c:\dbbasics\mydb.mdb")
    Set rs = db.OpenRecordset("tblmytable", dbOpenSnapshot)
    Label1.Caption = rs!Mytext
    Label2.Caption = rs!MyName

    End Sub

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    To Add Data to a Table in the Database, Open it as normal, then use the AddNew Method to add a new Blank Record, or use the Edit Method to edit the values of the currently selected Record, then assign the Values to the Approperiate field(s), before finally calling the Update Method to commit the addition/changes, ie.
    Code:
    rs.AddNew
    rs!MyText = "Blah"
    rs.Update
    
    'Or
    
    r.Edit
    rs!MyText = "Updated Blah"
    rs.Update

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width