I have a form with 6 checkboxes (getting their values from a table/query)
When the form loads, I would like the buttons right of the checkboxes to "react" to the values in the chekcboxes.
For example: If "Value1" is 0, then disable "EDIT" button and enable "ADD" button Else enable "Edit" button and disable "ADD" button.
Here is a screenshot:
I read some help files and wrote this:
Expand|Select|Wrap|Line Numbers
- Private Sub Form_Load()
- Dim Edit As String
- Dim Add As String
- Dim Value As String
- Edit = "cmd_edit1"
- Add = "cmd_add1"
- Value = "Value1"
- If Me(Value) = 0 Then
- Me(Edit).Enabled = False
- Me(Add).Enabled = True
- Else
- Me(Edit).Enabled = True
- Me(Add).Enabled = False
- End If
I should probably use Array and store variables there and then use a Do Loop.
I figured out how to declare Arrays, but I get lost, when it comes to looping the above code for every value in the array.
Here is the array example:
Expand|Select|Wrap|Line Numbers
- Dim Edit(6) As String
- Dim Add(6) As String
- Dim Value(6) As String
- Edit(1) = "cmd_edit1"
- Edit(2) = "cmd_edit2"
- Edit(3) = "cmd_edit3"
- Edit(4) = "cmd_edit4"
- Edit(5) = "cmd_edit5"
- Edit(6) = "cmd_edit6"
- Add(1) = "cmd_add1"
- Add(2) = "cmd_add2"
- Add(3) = "cmd_add3"
- Add(4) = "cmd_add4"
- Add(5) = "cmd_add5"
- Add(6) = "cmd_add6"
- Value(1) = "Value1"
- Value(2) = "Value2"
- Value(3) = "Value3"
- Value(4) = "Value4"
- Value(5) = "Value5"
- Value(6) = "Value6"
Friderik