Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
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-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated