Results 1 to 8 of 8
  1. #1
    Join Date
    May 2007
    Posts
    3

    Smile Unanswered: How to write code in VB 6 Excel that appends data into an access table (was "Dar256")

    How to write code in VB 6 Excel that appends data into an access table.

  2. #2
    Join Date
    Aug 2006
    Posts
    559
    This may have been better posted in the Excel Discussion Board on the forum.

    I don't believe its that difficult,

    You can probably start with :

    Private Sub Command1_Click()
    Dim strname As String
    strname = App.Path & "\chien.xls"
    Close #1
    Open strname For Append Access Read Write As #1
    Print #1, Text1.Text & vbTab & Text2.Text & vbCrLf & Text3.Text
    Close #1
    End Sub

  3. #3
    Join Date
    May 2005
    Posts
    1,191
    I'm not entirely sure what you're asking...
    Me.Geek = True

  4. #4
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,468
    Provided Answers: 10
    in excel I would do something like this

    Code:
    Dim MSdata As Database
    Dim Rst As Recordset
    
    '1 create a link to the database
    Set MSdata = OpenDatabase("fath_and_databasename.mdb", , False)
    ' and error i have found he is the it does not like long file name have to use the ~
    '2 open the table
    Set Rst = MSdata.OpenRecordset("table_or_sql")
    '3 you are in
    Rst.adnew
    bla
    bla
    Rst.close
    MSdata.Close
    Set MSdata = Nothing
    don't forget to

    tool -> References

    and pick microsoft DAO 3.51 object library
    Last edited by myle; 05-30-07 at 15:35.
    hope this help

    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.
    DONT WORRY ABOUT THOSE WHO TALK BEHIND YOUR BACK
    THEY'RE BEHIND YOU FOR A REASON

  5. #5
    Join Date
    May 2007
    Posts
    3
    The user would like to click a button and the excel spreadsheet inserts into an access 2000 table. The ODBC connection works when I get access data into excel. When I use the followng Dim MSdata As Database, Dim Rst As Recordset I get compile errors. DAO and ADO connection don't seem to work. I can write VB code, not good with MS Access connection stuff in Excel Visual Basic. Thanks for any help.
    Last edited by dar256; 05-31-07 at 21:35.

  6. #6
    Join Date
    Aug 2006
    Posts
    559
    Look through the "code bank" for a post by pkstormy about importing files, it may help you.

  7. #7
    Join Date
    May 2007
    Posts
    3
    I'll look through the code bank. Thank you!

  8. #8
    Join Date
    Aug 2006
    Posts
    559
    You're welcome. Let us know if it works for you, if not, I'm sure we'll figure some thing out...

Posting Permissions

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