PDA

Click to See Complete Forum and Search --> : Updating a table in an access database!!!! Please help


kanejone
Nov 23rd, 2000, 05:07 AM
Hi guys

I have the following code that connects to an access database.

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]

Jimbob
Nov 23rd, 2000, 06:24 AM
conn1.execute "UPDATE Table1 SET Cust1 = '" & Cust1 & "', cust2 = '" & cust2 & "', cust3 = '" & cust3 & "';"

kanejone
Nov 23rd, 2000, 06:26 AM
Thanks a million for the help. I really appreciate it.
JK

paulw
Nov 23rd, 2000, 06:57 AM
Note that an unrestricted update SQL statement will update ALL rows in the table with the same value. So, be careful.

P.

kanejone
Nov 23rd, 2000, 07:10 AM
Is there a way around this ????

Jimbob
Nov 23rd, 2000, 07:33 AM
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...