I'm trying to delete a single record from a rnd file using a delete button. On click the code below the problem seems to be with the keep statement. I keep getting a compile error:invalid qualifier on selectedbook even though the value matches the position of the record in the file. any ideas anyone ? :?:
Dim newrecordcount As Integer 'New recordcount for updated records'
Dim Book As BookType 'Book as single record'
Dim BookArray() As BookType 'Book array = dynamic'
ReDim BookArray(1 To recordcount) 'Redefine array to recordcount'
Dim N As Integer 'Define loop variable'
selectedbook.keep = False 'flag book record to remove'
Open filename For Random As #1 Len = Len(Book) 'Open file'
For N = 1 To recordcount
Get #1, N, Book
If selectedbook = True Then 'populate array'
newrecordcount = newrecordcount + 1 'with records but flag'
BookArray(newrecordcount) = Book 'selectedbook as false'
End If
Next N
Close #1 'close file
Kill filename 'kill file'
The file can then be rewritten to the same file path.