|
Dim db as DataBase
Dim rs As RecordSet Dim t% Dim SQL$ Const tbnaam$ = [yourtablename] Const DBNaam$ = [yourdatabasename] Set db = OpenDatabase(DBNaam) t% = 1 SQL$ = "SELECT * FROM " & tbnaam & " ORDER BY number" Set rs = db.OpenRecordset(SQL$) Do While Not rs.EOF If rs.Fields(0).Value <> t% Then 'show number that's missing and do what you want MsgBox Str(rs.Fields(0).Value + 1) Exit Do End If rs.MoveNext t% = t% + 1 Loop 'no number-gap so use t% as new counternumber 'You see.. it's possible but when your database is getting very large 'then it will cost some time to search for a number-gap. |