| Private Sub Command1_Click()
Dim db_file As String
Dim statement As String
Dim conn As ADODB.Connection
Dim ctl As Control
    ' Get the data.
    db_file = App.Path
    If Right$(db_file, 1) <> "\" Then db_file = db_file & _
        "\"
    db_file = db_file & "people.mdb"
    ' Open a connection.
    Set conn = New ADODB.Connection
    conn.ConnectionString = _
        "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=" & db_file & ";" & _
        "Persist Security Info=False"
    conn.Open
    ' Compose the INSERT statement.
    statement = "INSERT INTO Addresses " & _
        "(Name, Street, City, State, Zip) " & _
        " VALUES (" & _
        "'" & Replace$(txtName.Text, "'", "''") & "', " & _
        "'" & Replace$(txtStreet.Text, "'", "''") & "', " & _
            _
        "'" & Replace$(txtCity.Text, "'", "''") & "', " & _
        "'" & Replace$(txtState.Text, "'", "''") & "', " & _
        "'" & Replace$(txtZip.Text, "'", "''") & "'" & _
        ")"
    ' Execute the statement.
    conn.Execute statement, , adCmdText
    ' Close the connection.
    conn.Close
    ' Clear the TextBoxes.
    For Each ctl In Controls
        If TypeOf ctl Is TextBox Then
            ctl.Text = ""
        End If
    Next ctl
End Sub |