S
Spanky
Hi,
Having some issues deleting records from a table based on a text field in
that table.
I want to delete all fields in the table 'tblTags' inserted by an auto
process, creatively designated by the text "auto" in a field 'DataEntry'. The
code is triggered by a button on a form that is used to manage this data.
The current code is:
-------------------
Private Sub btnUpdateTags_Click()
On Error GoTo Err_btnUpdateTags_Click
Dim rsttest As Recordset
Dim strSQL As String
If MsgBox("Delete all Auto records from tblTags ?", vbYesNo) = vbYes Then
Set rsttest = CurrentDb.OpenRecordset("SELECT * FROM tblTags")
rsttest.MoveFirst
While Not rsttest.EOF
strSQL = "DELETE FROM [tblTags] WHERE [tblTags.DataEntry] = """ & auto &
""""
CurrentDb.Execute strSQL, dbFailOnError
rsttest.MoveNext
Wend
End If
Exit_btnUpdateTags_Click:
Exit Sub
Err_btnUpdateTags_Click:
MsgBox Err.Description
Resume Exit_btnUpdateTags_Click
End Sub
-------------------------
Summary is code doesn't delete anything. If I replace
""" & auto &"""" with """ & 1 & """" and put some corresponding 1's in
the table, it works fine, so I assume I've stuffed up the syntax for dealing
with text values somehow.
Any helpmuch appreciated.
ps. also tried
strSQL = "DELETE FROM [tblTags] WHERE [tblTags.DataEntry] = '" & auto & "'",
same result.
Having some issues deleting records from a table based on a text field in
that table.
I want to delete all fields in the table 'tblTags' inserted by an auto
process, creatively designated by the text "auto" in a field 'DataEntry'. The
code is triggered by a button on a form that is used to manage this data.
The current code is:
-------------------
Private Sub btnUpdateTags_Click()
On Error GoTo Err_btnUpdateTags_Click
Dim rsttest As Recordset
Dim strSQL As String
If MsgBox("Delete all Auto records from tblTags ?", vbYesNo) = vbYes Then
Set rsttest = CurrentDb.OpenRecordset("SELECT * FROM tblTags")
rsttest.MoveFirst
While Not rsttest.EOF
strSQL = "DELETE FROM [tblTags] WHERE [tblTags.DataEntry] = """ & auto &
""""
CurrentDb.Execute strSQL, dbFailOnError
rsttest.MoveNext
Wend
End If
Exit_btnUpdateTags_Click:
Exit Sub
Err_btnUpdateTags_Click:
MsgBox Err.Description
Resume Exit_btnUpdateTags_Click
End Sub
-------------------------
Summary is code doesn't delete anything. If I replace
""" & auto &"""" with """ & 1 & """" and put some corresponding 1's in
the table, it works fine, so I assume I've stuffed up the syntax for dealing
with text values somehow.
Any helpmuch appreciated.
ps. also tried
strSQL = "DELETE FROM [tblTags] WHERE [tblTags.DataEntry] = '" & auto & "'",
same result.