Multi-select List Box

R

rstuppi

I have a multi-select list box on a form. Each selected item in the
list will correspond to a record in the "many table" of a one-to-many
relationship.

I understand that as a result the list box is unbound.

I understand that selecting or unselecting items in the list will NOT
set the dirty flag on the form.

I understand that I have to manually update the "many table" using the
selected items in the list box.

I understand that the accepted way to mange the updates to the "many
table", according to Google search results, is via the list box's
BeforeUpdate event. So each time a item is selected or unselected I
have to update and/or delete and/or insert into the data source?
That's potentially quite a few DM operations not to mention the round
trips.

Ideally, I'd like to do the DM on the form's BeforeUpdate event.
Afterall, if the selected items in the list box have changed isn't the
form dirty? (Yes, I know, the list box is unbound.).

So far my best hack has been to do a Me.someControl = Me.someControl
in the list box's BeforeUpdate event which of course sets the form's
dirty flag. A call to Is Dirty = False throws some kind of bizzare
error that I could ignore but that seems even worse. A subform would
be ugly and in this app's situation presents other distasteful issues.

Does anyone have a better idea?
 
D

Douglas J. Steele

I don't see how setting the form's Dirty flag will help you that much.

You're still going to have to loop through all of the selected rows in the
list box and write to the table, one entry at a time.

You could put logic in the form's Unload event to see whether the
ItemsSelected property of the list box is greater than 0 (in which case you
know you need to do the updates), or you could simply put a button that the
user clicks on once he/she has selected everything of interest in the list
box.
 
R

rstuppi

I don't see how setting the form's Dirty flag will help you that much.

You're still going to have to loop through all of the selected rows in the
list box and write to the table, one entry at a time.

You could put logic in the form's Unload event to see whether the
ItemsSelected property of the list box is greater than 0 (in which case you
know you need to do the updates), or you could simply put a button that the
user clicks on once he/she has selected everything of interest in the list
box.

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no private e-mails, please)













- Show quoted text -

Thanks Doug, I'll look into the Unload event.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top