473,394 Members | 1,739 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Is There a batter way to implement Checkboxes?

1
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.
Expand|Select|Wrap|Line Numbers
  1. //code for the actual checkbox
  2. Private Sub chkbed_Click()
  3.  
  4. bedchk = False
  5.  
  6. 'vbchecked is a reserved word
  7. chkBed.Value = vbChecked
  8. bedchk = True
  9.  
  10. End Sub
  11.  
  12. //adds to the patients equipment in the database
  13. 'customers only get one thing of each equip
  14. add = 1
  15.  
  16. 'Adding equipment to patient
  17. With rspatientequip
  18. .AddNew
  19.  
  20. id = getCustID
  21.  
  22. !CustId = id
  23.  
  24. If addequip = True Then
  25. !bed = "bed"
  26.  
  27. End If
  28. rspatient.Update
  29. End With
  30.  
  31.  
  32. //code for updating inventory
  33.  
  34. Dim id As String
  35. 'customers only get one thing of each equip
  36. reduce = 1
  37.  
  38.  
  39.  
  40. 'taking away from inventory, Updates inventory field UNitIn Stock - reduce(1)
  41. Dim newDBInstockValue As Integer
  42. Dim dbInStock As Integer
  43.  
  44. With rsinventory
  45.     .MoveFirst
  46.     .Find "ProductName = 'Bed'"
  47.     dbInStock = !UnitInStock
  48.  
  49.     newDBInstockValue = (dbInStock - reduce)
  50.     !UnitInStock = newDBInstockValue
  51.  
  52. rsinventory.Update
  53. End With
  54.  
Oct 7 '06 #1
0 897

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Pete | last post by:
There is a Summary/Example further down... On page one of my site I have a form with some checkboxes and detailed descriptions. When the form is submitted (to page two), the values of the...
4
by: Matt | last post by:
In ASP page, there is a "SELECT ALL" button, when user click it, it will select all checkboxes. I am not sure should I use client-side code to do that? the following is my approach but it didnt...
8
by: DylanM | last post by:
I have some checkboxes that are generated from the results of a database search. At the moment, the checkboxes are part of a table making up a form. Users are going through the form, clicking the...
6
by: terence.parker | last post by:
I currently have the following JS in my header: function checkall(thestate) { var checkboxes=eval("document.forms.EssayList.file_id") for (i=0;i<checkboxes.length;i++)...
7
by: Jaime Stuardo | last post by:
Hi all.. I have a DataGrid with checkboxes. In the header I have a "check all" checkbox. I'm wondering if there is an easy way to check all checkboxes using that checkbox. I could do it using...
10
by: rn5a | last post by:
All the rows in a DataGrid, including the Header, are accompanied with a CheckBox. I want that when the CheckBox in the Header is checked, then all the CheckBoxes should automatically get checked....
5
by: masterej | last post by:
Developers, Is there any way to disable all checkboxes on a form? I have a form with 160 checkboxes and I want to be able to disable all of them. Is there a way I can do something like this: ...
8
by: PeteOlcott | last post by:
http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/grid/tests/test_change_structure.html I would like to completely understand how GUI controls such as this one are constructed. In the...
7
by: viki1967 | last post by:
I need one function javascript that: 1) when I enter in this htm page I see enabled only checkbox of categories A, M and T; checkboxes of microcategories all disabled; 2-a) If I select the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.