Results 1 to 6 of 6

Thread: Updating a table in an access database!!!! Please help

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    224
    Hi guys

    I have the following code that connects to an access database.
    Code:
    Dim AccessConnect As String
    AccessConnect = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
                       "DBQ=Hello.mdb;" & _
                       "DefaultDir=" & App.Path & ";" & _
                       "UID=admin;PWD=;"
                       
    Dim Conn1 As ADODB.Connection
    Dim Cmd1 As ADODB.Command
    Dim Params1 As ADODB.Parameters
    Dim Param1 As ADODB.Parameter
    Dim Rs1 As ADODB.Recordset
    Dim i As Integer
          
    Set Conn1 = New ADODB.Connection
    Conn1.ConnectionString = AccessConnect
    Conn1.Open
    I also have 3 variables that are called CUST1 CUST2 and CUST3. I am trying to figure out how to send these variables to a table called Table1 in the first 3 fields called CUST1 CUST2 and CUST3. Thanks a million for any help that anyone may be able to offer.
    Cheers
    JK

    [Edited by kanejone on 11-29-2000 at 05:09 AM]

  2. #2
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Isle of Man
    Posts
    276
    conn1.execute "UPDATE Table1 SET Cust1 = '" & Cust1 & "', cust2 = '" & cust2 & "', cust3 = '" & cust3 & "';"

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    224

    Wink Cheers

    Thanks a million for the help. I really appreciate it.
    JK

  4. #4
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    Note that an unrestricted update SQL statement will update ALL rows in the table with the same value. So, be careful.

    P.
    Not nearly so tired now...

    Haven't been around much so be gentle...

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    224

    Wink

    Is there a way around this ????

  6. #6
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Isle of Man
    Posts
    276
    oops, sorrry about that!

    yes, just add a WHERE clause to the end the query

    eg WHERE ColName <10

    bit of an oversight on my part there...

Posting Permissions

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



Click Here to Expand Forum to Full Width