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.
Expand|Select|Wrap|Line Numbers
- //code for the actual checkbox
- Private Sub chkbed_Click()
- bedchk = False
- 'vbchecked is a reserved word
- chkBed.Value = vbChecked
- bedchk = True
- End Sub
- //adds to the patients equipment in the database
- '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
- //code for updating inventory
- 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