Is There a batter way to implement Checkboxes?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ched35
    New Member
    • Oct 2006
    • 1

    #1

    Is There a batter way to implement Checkboxes?

    I am basically writting a program to assign inventory to a patient. The inventory is being added to the database by checkboxes. So when they click each of the check boxes, 1 is added to each of their equipment signed out. and inventory is decremented by 1 for each equipment.

    When the Submit button is clicked everything is added to the DB.


    Question:

    As I am writting this, I realised if there was 100 pieces of equipment, that would take me forever to write. I am only using 20 equipments--i.e checkboxes.

    The code below would have to be written for each checkbox selected. Is there a better way?

    Here is what I came up with.
    Code:
    [B]
    //code for the actual checkbox[/B]
    Private Sub chkbed_Click()
    
    bedchk = False
    
    'vbchecked is a reserved word
    chkBed.Value = vbChecked
    bedchk = True
    
    End Sub
    
    [B]//adds to the patients equipment in the database[/B]
    'customers only get one thing of each equip
    add = 1
    
    'Adding equipment to patient
    With rspatientequip
    .AddNew
    
    id = getCustID
    
    !CustId = id
    
    If addequip = True Then
    !bed = "bed"
    
    End If
    rspatient.Update
    End With
    [B]
    
    
    //code for updating inventory[/B]
    
    Dim id As String
    'customers only get one thing of each equip
    reduce = 1
    
    
    
    'taking away from inventory, Updates inventory field UNitIn Stock - reduce(1)
    Dim newDBInstockValue As Integer
    Dim dbInStock As Integer
    
    With rsinventory
        .MoveFirst
        .Find "ProductName = 'Bed'"
        dbInStock = !UnitInStock
        
        newDBInstockValue = (dbInStock - reduce)
        !UnitInStock = newDBInstockValue
        
    rsinventory.Update
    End With
Working...