I
iris
I am trying to delete a record from an access database.
This is my code:
Dim dbDatabase As Database
Dim rs As Recordset
Dim e As Integer
Dim d As Boolean
Set dbDatabase = OpenDatabase("C:\mydata1.mdb")
Set rs = dbDatabase.OpenRecordset("SELECT * FROM expressions ORDER by heb;",
dbOpenSnapshot)
Dim eStr As String
Dim answer As String
d = False
e = 0
With rs
Do Until .EOF
If ComboBox2.Text = ![heb] Then
answer = MsgBox("Do you want to delete this record: " &
ComboBox2.Text, vbQuestion + vbYesNo)
If answer = vbNo Then
Exit Sub
Else
answer = MsgBox("Are you shure you want to delete
this record: " & ComboBox2.Text, vbQuestion + vbYesNo)
If answer = vbNo Then
Exit Sub
Else
rs.Delete
MsgBox "the record " & ![heb] & " has been
deleted"
End If
End If
End If
.MoveNext
e = e + 1
Loop
End With
rs.Close
dbDatabase.Close
I get an error the rs.delete....
Can someone tell me what I am doing wrong please?
This is my code:
Dim dbDatabase As Database
Dim rs As Recordset
Dim e As Integer
Dim d As Boolean
Set dbDatabase = OpenDatabase("C:\mydata1.mdb")
Set rs = dbDatabase.OpenRecordset("SELECT * FROM expressions ORDER by heb;",
dbOpenSnapshot)
Dim eStr As String
Dim answer As String
d = False
e = 0
With rs
Do Until .EOF
If ComboBox2.Text = ![heb] Then
answer = MsgBox("Do you want to delete this record: " &
ComboBox2.Text, vbQuestion + vbYesNo)
If answer = vbNo Then
Exit Sub
Else
answer = MsgBox("Are you shure you want to delete
this record: " & ComboBox2.Text, vbQuestion + vbYesNo)
If answer = vbNo Then
Exit Sub
Else
rs.Delete
MsgBox "the record " & ![heb] & " has been
deleted"
End If
End If
End If
.MoveNext
e = e + 1
Loop
End With
rs.Close
dbDatabase.Close
I get an error the rs.delete....
Can someone tell me what I am doing wrong please?