Solved Keeping track of "slots" within a space limited list as items added/removed/amended (1 Viewer)

Sanguineus

New member
Local time
Today, 10:30
Joined
May 5, 2020
Messages
13
I have a listbox (that is bound to a table) that I will constrain to being able to hold at most 5 items. The listbox is split into three columns TimerNumber (integer 1 to 5), TimerName (string) and TimerValue (double).

I have controls set up that will allow the use to add and remove items from the listbox, but what I can't figure out is how to keep track and then allocate TimerNumbers.

For example:

User adds a timer which being the first item is allocated 1, they then add another which is allocated 2 - so far so good.
They then remove the timer in slot 1 so of the 5 slots only slot 2 is in use. Then user then adds another timer, which I would like to go back to slot 1.
I've spent a few hours over the course of the last couple of days trying to figure how to keep track of the available timer numbers...

Hopefully this makes sense!
 

Sanguineus

New member
Local time
Today, 10:30
Joined
May 5, 2020
Messages
13
wouldn't listbox.listcount only tell me a count of items within the listbox not the position. so for example if slots 2, 3, 4 & 5 were in use, the return from the count would be 4, not the required 1 in this case.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 18:30
Joined
May 7, 2009
Messages
19,175
how was your table structured?
when you mean add a timer, you add a record to the table with
the value of that timer?
 

Sanguineus

New member
Local time
Today, 10:30
Joined
May 5, 2020
Messages
13
Table is a physical table within the DB, with the fields listed above (plus the name of the user).

The timer value is a value from a timer class i'm using, and the value will be updated by the forms ontimer event, (once I figure out how to keep track of which slots are in use). There are 5 (hence the limit for now) public timers on the form Timer1 - Timer5 the class has a property for the start time, end time, name, as well asfunctions to retrieve the elapsed time (which is what i'll be calling to update the value in the table, which will in turn update the listbox on the form).
 

Dreamweaver

Well-known member
Local time
Today, 10:30
Joined
Nov 28, 2005
Messages
2,466
You could use a tag in the table to show which items have been selected so if user selects item 2 then the table could be updated so item 2 selected entry it maked true.

is this a local table or will it be a shared table?
 

Sanguineus

New member
Local time
Today, 10:30
Joined
May 5, 2020
Messages
13
At the moment its going to be a shared table on a backend just so that I can keep track of whats going on for who, but if there's a performance impact i'll make it a local table. I wasn't aware that we could limit a table to a fixed number of entries (never had a need to before now) but if that's the case would make things a lot easier, would just need to select the lowest "row" number thats vacant.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 18:30
Joined
May 7, 2009
Messages
19,175
so it is not Bound to another table?
then why not use a Datasheet subform.
using its recordsetclone you can check which Timer Number is missing (deleted).
 

Sanguineus

New member
Local time
Today, 10:30
Joined
May 5, 2020
Messages
13
I used a listbox because it looked nicer on my form (/shame) i'll take a look at a subform.. and then read about recordsetclones. I'm just at the startof my Access/vba journey it seems.

thank you for the tip!
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 18:30
Joined
May 7, 2009
Messages
19,175
with datasheet subform you can program the "Delete" behavior.
instead of physically deleting the record, you can just make the
Fields (excluding the TimerNumber), blank or null.
therefore you only need to Insert the New timer to
the "first" record with Blank TimerName.
 

Users who are viewing this thread

Top Bottom