Villarreal68
Registered User.
- Local time
- Today, 09:29
- Joined
- Feb 15, 2007
- Messages
- 133
Hello everyone,
I have a database that populates rooms with occupants for classes or meetings. I have two listboxes, one has the potential occupants and the other the list of already assigned occupants to the room. So far so good.
Then I have a button that will move any one selection on the "Potential Occupants list" to the "Assigned Room Occupants" with the following code on it:
This works as expected. But with this code you can go forever adding occupants to a room.
What I want to accomplish is to be able to limit the amout of occupants to the number of chairs in the room. I already have a field that has the number of chairs in my rooms table, but i don't know how to modify the code to stop the assignments once the limit has been reached.
Any help would be truly appreciated. thanks!
René
I have a database that populates rooms with occupants for classes or meetings. I have two listboxes, one has the potential occupants and the other the list of already assigned occupants to the room. So far so good.
Then I have a button that will move any one selection on the "Potential Occupants list" to the "Assigned Room Occupants" with the following code on it:
Code:
Dim varitem As Variant
Dim count As Integer
Dim rsCM As Object
For Each varitem In OcupantesList.ItemsSelected
count = count + 1
Next varitem
If count = 0 Then
MsgBox "No se ha seleccionado ningún Ocupante"
Exit Sub
End If
Set rsCM = CurrentDb.OpenRecordset("Asignaciones")
For Each varitem In OcupantesList.ItemsSelected
rsCM.AddNew
rsCM.OcupanteID = CInt(Forms!NuevaAsignaciones!OcupantesList.ItemData(varitem))
rsCM.InvitadoID = Forms!NuevaAsignaciones!txtInvitadoID
rsCM.NumCuarto = Forms!NuevaAsignaciones!txtNumCuarto
rsCM.FechaLlegada = Me.txtfechallegada
rsCM.FechaSalida = Me.txtfechasalida
rsCM.Update
Next varitem
This works as expected. But with this code you can go forever adding occupants to a room.
What I want to accomplish is to be able to limit the amout of occupants to the number of chairs in the room. I already have a field that has the number of chairs in my rooms table, but i don't know how to modify the code to stop the assignments once the limit has been reached.
Any help would be truly appreciated. thanks!
René