My problem is how could I get previos record in the form after I had
deleted the current record.
What should I write after code below ? docmd.showallrecords or what ?
If I do so I'll get error message: "Index or primary key cannot
contain a Null Value"
I'am trying to delete current record with following code in vba:
Private Sub Delete_record (glngLasno as long)
Set dbsCurrent = CurrentDb()
strSql = "SELECT * FROM bill where [company]= '" & gstrComp & "'
and lasno = " & glngLasno & ";"
Set rstBill = dbsCurrent.OpenRecordset(strSql)
If rstBill.EOF Or rstBill.BOF Then
Set dbsCurrent = Nothing
Set rstBill = Nothing
Exit Sub
End If
Application.Echo False
Do Until rstBill.EOF
rstBill.Delete
rstBill.MoveNext
Loop
MsgBox ("Deleted !")
rstBill.Close
dbsCurrent.Close
Set dbsCurrent = Nothing
Set rstBill = Nothing
Application.Echo True
Exit Sub
err_sec:
Set dbsCurrent = Nothing
Set rstBill = Nothing
MsgBox Err.Description
Exit Sub
End Sub
Colpo