DAO Recordset Record Won't Delete

  • Thread starter Thread starter Brandon Johnson
  • Start date Start date
B

Brandon Johnson

When i try to run this code (snipped), i get an error... runtime error
3021no current record. However, I see no problem with this code as i
have the same record in both recordsets that im trying to delete. If
anyone has any other additional qs please let me know. thankyou.
cred = "[login_name] = '" & lstNames.ItemData(i) & "'"
user.FindFirst cred
status.FindFirst cred
If MsgBox("Are you sure you want to delete user: " &
user!login_name, vbYesNo,
"Question") = vbYes Then
status.Delete 'FIX - WON'T
DELETE!!!!!!!!!!!!!
user.Delete
lstNames.RowSource = "SELECT login_name FROM
tblLoginPWD ORDER BY login_name asc;"
txtNameCount = lstNames.ListCount
Else
MsgBox "User: " & user!login_name & " was NOT
deleted.", vbInformation, "Information"
Exit Sub
End If
 
Are you sure that cred is correct: that you're actually finding the records?

Check whether user.NoMatch and/or status.NoMatch are true before you try
deleting: if they are, you can't delete.
 
Ya i understand where your coming from on that. but the thing that i
cant get over is that i physically opened the tables after that msg and
saw the entries in the tables. thats why i didnt put in the nomatch. do
you think it could be anything else? like order of which things come
into play or anything?
 
Check things in a logical order!

The first potential point of failure is that the value of cred isn't
correct. What is its value?

In my opinion, you put in error handling right from the start. It's amazing
how often it's necessary!
 
Back
Top