AI bliver først for alvor en del af arbejdet, når teknologien integreres i den måde, vi arbejder på. At have adgang til AI betyder ikke nødvendigvis, at medarbejderne er klar til at bruge den.
No I am afraid that index is not a field, if so it would be easy to solve. The problem is that I might delete e.g row 4, and then I have no runningnumber, so therefore I need a way to count the records and delete the right one which corrosponse to the on in the listbox
Dim dbsNorthwind As Database Dim rstSuppliers As Recordset Dim varBookmark As Variant Dim strCommand As String Dim lngMove As Long
Set dbsNorthwind = OpenDatabase(\"Northwind.mdb\") Set rstSuppliers = dbsNorthwind.OpenRecordset(\"SELECT CompanyName, \" & _ \"City, Country FROM Suppliers ORDER BY CompanyName\", _ dbOpenDynaset)
With rstSuppliers \' Populate recordset. .MoveLast .MoveFirst
Do While True
\' Display information about current record and ask \' how many records to move. strCommand = InputBox( _ \"Record \" & (.AbsolutePosition + 1) & \" of \" & _ .RecordCount & vbCr & \"Company: \" & _ !CompanyName & vbCr & \"Location: \" & !City & _ \", \" & !Country & vbCr & vbCr & _ \"Enter number of records to Move \" & _ \"(positive or negative).\")
If strCommand = \"\" Then Exit Do
\' Store bookmark in case the Move doesn\'t work.
varBookmark = .Bookmark
\' Move method requires parameter of data type Long. lngMove = CLng(strCommand) .Move lngMove
\' Trap for BOF or EOF. If .BOF Then MsgBox \"Too far backward! \" & _ \"Returning to current record.\" .Bookmark = varBookmark End If If .EOF Then MsgBox \"Too far forward! \" & _ \"Returning to current record.\" .Bookmark = varBookmark End If
Loop .Close End With
dbsNorthwind.Close
qdf.Close Set qdf = Nothing dbs.Close Set dbs = Nothing
The example is taken from Access help. From it you can see how you move around a recordset. Once you get to the correct record you can use the delete method:
rstSuppliers.delete
Oh! and the last four lines of the previous example can be removed.
Thank you for the help, just one more little think, I have perviously encountert the Bookmark, what is the concept of this, do you know? I can\'t quite grasp it.... ;)
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.