Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delete item from listbox

Status
Not open for further replies.

tonyx666

MIS
Apr 13, 2006
214
GB
i have a listbox that uses the 'row source type' as a value list.

i have another listbox that uses a row source type as a table/query.


on my VALUE LIST listbox, i am able to delete items from the listbox using the following code

Code:
Private Sub lstDriverTime_KeyDown(KeyCode As Integer, Shift As Integer)
 If KeyCode = 46 And Me.lstDriverTime.ListIndex <> -1 Then
   Me.lstDriverTime.RemoveItem (lstDriverTime.ListIndex)
 End If
End Sub

i tried using this same method for my listbox that displays details from a query.. (so that records can be deleted from the listbox in the same way)

but the database told me that this will only work if the listbox has a value list..

therefore my question is... can i implement the same 'removeitem' function on my listbox that uses a source from a table/query..
 
No.
You can remove them from your listbox by:
1. Remove them from the table.
2. Alter the query so the item is not selected.


Randy
 
Hi Tony,
Use DoCmd.RunSQL method to run query to delete the selected item from listbox from table.
Then requery ListBox.
Instead of
Me.lstDriverTime.RemoveItem (lstDriverTime.ListIndex)
 
ok i have an idea..

basically the listbox that i want to remove items from displays jobs (using the job date) that are today and tomorrow.. like so.. (this is in the date criteria)

Between Date() And 1+Date()

i also have a jobtime field.. where the times are in text format.. and entered as..

'0800' or '1210' or '1545'

what can i place in the jobtime criteria that will only display jobs that are to be done..

eg.. if the current time is 15.45 then remove jobs from the list that have elapsed ten minutes ago..

eg..

at 15.45.. it will remove a job that had a job time of 1535

will this work??
 
Why having 2 fields (jobdate and jobtime) to hold a single DateTime value ?
with a single field, say, jobDateTime, the criteria would simply be:
Between Now() And 1+Now()

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
yes i realise this..

this was one of the design decisions i made due to circumstances..

basically not all the jobs will be entered live.. and some jobs are taken on paper by users that have no computer literacy at all.. so they need to be manually entered a day or more later into the database.. etc

so with my situation as it is.. is there anyway to do what i asked.. just for the job time.. something like a ten minute buffer??

something like

Between Time() AND Time()+10minutes.. or something like that. i dunno

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top