Hi. I'm struggling to work out how to delete a record from a simple database I've been working on. The code is as follows:
Code:
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
If MessageBox.Show("Are you sure you want to permanently" & vbNewLine & _
"delete record number " & intCurrentRec & " ?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.No Then
Exit Sub
End If
If intNumberRecs > 0 Then
DeleteRec()

intNumberRecs = intNumberRecs - 1

If intNumberRecs = 0 Then
NewBoxes()

Else
If intCurrentRec = intNumberRecs + 1 Then
intCurrentRec = intNumberRecs

End If
GetRec(intCurrentRec)

DisplayRec()

End If
End If
End Sub
Private Sub DeleteRec()
Dim intFileNum1 As Int16 = FreeFile()
FileOpen(intFileNum1, strCustFName, OpenMode.Random, OpenAccess.ReadWrite, , intRecLength)

Dim intFileNum2 As Int16 = FreeFile()
FileOpen(intFileNum2,

"TEMP.DAT", OpenMode.Random, OpenAccess.ReadWrite, , intRecLength)
Dim intRecord As Int16
For intRecord = 1 To intNumberRecs
If intRecord <> intCurrentRec Then
FileGet(intFileNum2, aCustomer, )

End If
Next
FileClose(intFileNum1)

FileClose(intFileNum2)

Kill(strCustFName)

Rename(

"TEMP.DAT", strCustFName)
End Sub
I'd appreciate it if anyone could help me out.

Thanks

P.S. The NewBoxes() sub just deletes the text inside the text boxes. intNumberRecs is the number of records and intCurrentRec is the current record, both are int16