-
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
-
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