Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
TitleUse DAO to add records to a database
Keywordsdatabase, DAO, add record, insert record
CategoriesDatabase
 
Use the Database object's Execute method to execute an INSERT SQL statement.
 
' Add a record.
Private Sub cmdAdd_Click()
Dim query As String

    ' Create an INSERT action query.
    query = "INSERT INTO People VALUES("
    query = query & "'" & txtLastName.Text & "', "
    query = query & "'" & txtFirstName.Text & "', "
    query = query & "'" & txtId.Text & "'"
    query = query & ")"
    
    ' Execute the query.
    On Error GoTo NotInserted
    db.Execute query

    MsgBox "Ok"
    Exit Sub
    
NotInserted:
    MsgBox "Error" & Str$(Err.Number) & _
        " inserting record." & vbCrLf & _
        Err.Description
End Sub
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated