Change the version

Trinb37

Registered User.
Local time
Today, 14:48
Joined
Oct 9, 2003
Messages
23
I have come with this code, but it can only work on 2002 version of Access. The version I have is 2000. This is the code:

Dim intRecordID as Long, rst as ADODB.recordset
Dim strsql as string
intRecordID = me.list0
Set rst = New ADODB.Recordset
With rst
.activeconnection = currentproject
.connection
.locktype = adOptimistic
.cursortype = adForwardOnly 'I cant remember if this is the exact name of the constant
strsql = "SELECT * FROM tbl_tablename WHERE tblIDFIELD = " & intRecordID
.open strsql
.delete
.update
.close
End With
Set rst = nothing
Me.list0.RemoveItem (intRecordID)
end sub
Do you have any ideas on how to modify it to work?
James
 
It would have helped if you had indicated which line got the compile error. You seem to be confusing two different things. If the rowsource of your listbox is a query or table, you would delete the item from the table as you have done and then requery the listbox. The AddItem and RemoveItem methods only apply to listboxes who's rowsource type is ValueList. They will not work if the rowsource type is query/table. These methods are also not available in versions of Access earlier than XP. If you want to populate a listbox with VBA in earlier versions of Access, you need to use a callback function.
 

Users who are viewing this thread

Back
Top Bottom