-
Solved: SQL Update query problem
Can anyone tell me why the code below update query doesnt update my record?
I have a table called tbl_Test with field names
FieldName1
FieldName2
FieldName3
Thanks Gibbo
[VBA] Const adOpenForwardOnly As Long = 0
Const adLockReadOnly As Long = 1
Const adCmdText As Long = 1
Dim oConn As Object
Dim oRS As Object
Dim sConnect As String
Dim sSQL As String
Dim ary
sConnect = (stCon)
sSQL = "SELECT * From tbl_Test"
Set oRS = CreateObject("ADODB.Recordset")
oRS.Open sSQL, sConnect, adOpenForwardOnly, _
adLockReadOnly, adCmdText
' Check to make sure we received data.
If oRS.EOF Then
MsgBox "No records returned.", vbCritical
Else
sSQL = "UPDATE tbl_Test " & _
" SET FieldName3 = 'None' " & _
"WHERE FieldName1 = 'Me.TextBox1.Text' AND FieldName2 = 'Me.TextBox2.Text'"
oRS.ActiveConnection.Execute sSQL
sSQL = "SELECT * From tbl_Test"
oRS.ActiveConnection.Execute sSQL
ary = oRS.GetRows
MsgBox ary(0, 0) & " " & ary(1, 0) & ", " & ary(2, 0) & ", " & ary(3, 0)
End If
oRS.Close
Set oRS = Nothing [/VBA]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules